add more accurate error handling

This commit is contained in:
smanylov
2026-04-09 14:34:48 +07:00
parent 9c9bf201c4
commit 3a6034a460
+6 -1
View File
@@ -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,7 +381,10 @@ export async function createPayoutRequest(
} }
if (response.status === 409) { 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) { if (response.ok) {