Skip to content

Commit

Permalink
Update swapError.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
atn4z7 committed Jan 31, 2025
1 parent e8d8280 commit 23a7c70
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core-mobile/app/errors/swapError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ export function humanizeSwapError(err: unknown): string {
errorString.toLowerCase().startsWith('not enough') &&
errorString.includes('allowance')
) {
return 'Swap failed! Not enough allowance.'
return 'Not enough allowance.'
}

if (errorString.includes('-32000')) {
return 'Swap failed! Another transaction is pending. Rise gas price to overwrite it.'
return 'Another transaction is pending. Raise gas price to overwrite it.'
}

if (errorString.toLowerCase().includes('network error')) {
return 'Swap failed! Network error, please try again.'
return 'Network error, please try again later.'
}

if (err instanceof JsonRpcError) {
if (isError(err.cause, 'INSUFFICIENT_FUNDS'))
return `Swap failed! Insufficient amount for gas. Reduce swap quantity and try again.`
return 'Insufficient amount for gas. Reduce swap quantity and try again.'

return err.message
}

return 'Swap failed! Please try again.'
return errorString || 'An unknown error occurred'
}

0 comments on commit 23a7c70

Please sign in to comment.