internal/ethapi: able to returns bytes of the custom errors

This commit is contained in:
islishude 2024-03-24 12:47:35 +08:00
parent 064f37d6f6
commit 0f7056fc56

View file

@ -49,6 +49,8 @@ func newRevertError(revert []byte) *revertError {
reason, errUnpack := abi.UnpackRevert(revert) reason, errUnpack := abi.UnpackRevert(revert)
if errUnpack == nil { if errUnpack == nil {
err = fmt.Errorf("%w: %v", vm.ErrExecutionReverted, reason) err = fmt.Errorf("%w: %v", vm.ErrExecutionReverted, reason)
} else if len(revert) >= 4 {
err = fmt.Errorf("execution reverted with a custom error: %x", revert)
} }
return &revertError{ return &revertError{
error: err, error: err,