-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const ERRORS = { | ||
"TypeError: Cannot read properties of undefined (reading 'waitForResult')": | ||
'There was a problem.', | ||
'FuelError: not enough coins to fit the target': | ||
'FuelError: not enough coins to fit the target', | ||
'FuelError: The transaction reverted with reason: "…t/fuel_asm/enum.PanicReason.html#variant.OutOfGas': | ||
'Execution ran out of gas.', | ||
'FuelError: The transaction reverted because a "require" statement has thrown "NotCollateralized".': | ||
'Cannot withdraw more than collateralized. Try lowering the amount.', | ||
} as Record<string, string>; | ||
|
||
export const errorToMessage = (error: string) => { | ||
if ( | ||
error.startsWith( | ||
`FuelError: The transaction reverted with reason: "OutOfGas"` | ||
) | ||
) | ||
return 'Execution ran out of gas. Try again.'; | ||
return ERRORS[error] || 'An error occurred. Please try again later.'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters