mirror of
https://github.com/status-im/nim-ethers.git
synced 2025-02-01 01:55:38 +00:00
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…
x
Reference in New Issue
Block a user