fix: error handler

This commit is contained in:
Danil Kovtonyuk 2021-10-07 16:22:36 +10:00
parent ded50dc62b
commit 631a1c054a
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746

View File

@ -157,15 +157,8 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
}
}
handleError(e) {
// Sometimes ethers wraps known errors, unwrap it in this case
if (e?.error?.error) {
e = e.error;
}
const message = e?.error ? e.error.message : e.message;
const error = CONTRACT_ERRORS.find((e) => (typeof e === 'string' ? e === message : message.match(e)));
handleError({ message }: Error) {
const error = CONTRACT_ERRORS.find((knownError) => message.includes(knownError));
if (error) {
throw new Error(`Revert by smart contract: ${error}`);