[base-contract] throw string revert error (#2453)

This commit is contained in:
Jacob Evans
2020-01-24 07:48:26 +10:00
committed by GitHub
parent 02d14f504f
commit 277a0adac9
2 changed files with 13 additions and 4 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "6.1.1",
"changes": [
{
"note": "Throw Error when revert is StringRevertError",
"pr": 2453
}
]
},
{
"version": "6.1.0",
"changes": [

View File

@@ -142,14 +142,14 @@ export class BaseContract {
let revertError: RevertError;
try {
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) {
// Can't decode it.
return;
}
// Re-cast StringRevertErrors as plain Errors for backwards-compatibility.
if (revertError instanceof StringRevertError) {
throw new Error(revertError.values.message as string);
}
throw revertError;
}
protected static _throwIfUnexpectedEmptyCallResult(rawCallResult: string, methodAbi: AbiEncoder.Method): void {