@0x/base-contract
: Re-wrap StringRevertError
s as plain Error
s for backwards compatibility
This commit is contained in:
parent
aebb923c2d
commit
3de13967bc
@ -8,6 +8,7 @@ import {
|
|||||||
decodeThrownErrorAsRevertError,
|
decodeThrownErrorAsRevertError,
|
||||||
providerUtils,
|
providerUtils,
|
||||||
RevertError,
|
RevertError,
|
||||||
|
StringRevertError,
|
||||||
} from '@0x/utils';
|
} from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import {
|
import {
|
||||||
@ -128,6 +129,10 @@ export class BaseContract {
|
|||||||
let revertError: RevertError;
|
let revertError: RevertError;
|
||||||
try {
|
try {
|
||||||
revertError = decodeThrownErrorAsRevertError(error);
|
revertError = decodeThrownErrorAsRevertError(error);
|
||||||
|
// Re-cast StringRevertErrors as plain Errors for backwards-compatibility.
|
||||||
|
if (revertError instanceof StringRevertError) {
|
||||||
|
throw new Error(revertError.values.message as string);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Can't decode it.
|
// Can't decode it.
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user