improve decoding failure messages

Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
This commit is contained in:
Mark Spanbroek 2024-05-15 13:36:56 +02:00 committed by markspanbroek
parent 131316de08
commit 2da59a86c3
1 changed files with 2 additions and 2 deletions

View File

@ -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)