add more accurate error handling
This commit is contained in:
@@ -360,6 +360,8 @@ export async function createPayoutRequest(
|
|||||||
const amount = formData.get('amount') as string || '';
|
const amount = formData.get('amount') as string || '';
|
||||||
const payoutMethodId = formData.get('payoutMethodId') as string || '';
|
const payoutMethodId = formData.get('payoutMethodId') as string || '';
|
||||||
|
|
||||||
|
console.log('createPayoutRequest');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE_URL}/api/payouts/create-request`, {
|
const response = await fetch(`${API_BASE_URL}/api/payouts/create-request`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -379,8 +381,11 @@ export async function createPayoutRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 409) {
|
if (response.status === 409) {
|
||||||
|
const responseText = await response.text();
|
||||||
|
if (responseText.includes('Not have money for payout')) {
|
||||||
throw 'insufficient-funds-to-receive-payment'
|
throw 'insufficient-funds-to-receive-payment'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const parsed = await response.json();
|
const parsed = await response.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user