improve decoding failure messages
Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
This commit is contained in:
parent
131316de08
commit
2da59a86c3
|
@ -21,12 +21,12 @@ func decode*[E: SolidityError](_: type E, data: seq[byte]): ?!(ref E) =
|
|||
return failure "unable to decode " & $E & ": selector doesn't match"
|
||||
when compiles(E.arguments):
|
||||
without arguments =? E.decodeArguments(data), error:
|
||||
return failure "unable to decode " & $E & ": " & error.msg
|
||||
return failure "unable to decode arguments of " & $E & ": " & error.msg
|
||||
let message = "EVM reverted: " & $E & $arguments
|
||||
success (ref E)(msg: message, arguments: arguments)
|
||||
else:
|
||||
if data.len > 4:
|
||||
return failure "unable to decode " & $E & ": unread trailing bytes found"
|
||||
return failure "unable to decode: " & $E & ".arguments is not defined"
|
||||
let message = "EVM reverted: " & $E & "()"
|
||||
success (ref E)(msg: message)
|
||||
|
||||
|
|
Loading…
Reference in New Issue