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 payoutMethodId = formData.get('payoutMethodId') as string || '';
|
||||
|
||||
console.log('createPayoutRequest');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/payouts/create-request`, {
|
||||
method: 'POST',
|
||||
@@ -379,7 +381,10 @@ export async function createPayoutRequest(
|
||||
}
|
||||
|
||||
if (response.status === 409) {
|
||||
throw 'insufficient-funds-to-receive-payment'
|
||||
const responseText = await response.text();
|
||||
if (responseText.includes('Not have money for payout')) {
|
||||
throw 'insufficient-funds-to-receive-payment'
|
||||
}
|
||||
}
|
||||
|
||||
if (response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user