-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation and error handing for --code-a/--code-b #583
Conversation
looks good, although maybe this should be a validation error instead of an internal error? |
Good point actually! I have now changed it so it gives us a normal error: $ cabal run -f devel exe:hevm -- equivalence --code-a <(cat a.txt) --code-b <(cat b.txt)
hevm: Invalid hex bytestring provided for '--code'. Bytestring provided: '"/proc/self/fd/13"'
CallStack (from HasCallStack):
error, called at src/EVM/Format.hs:831:10 in hevm-0.53.0-inplace:EVM.Format I hope this is better! |
src/EVM/Format.hs
Outdated
@@ -828,7 +828,7 @@ hexByteString :: String -> ByteString -> ByteString | |||
hexByteString msg bs = | |||
case BS16.decodeBase16Untyped bs of | |||
Right x -> x | |||
_ -> internalError $ "invalid hex bytestring for " ++ msg | |||
_ -> error $ "Invalid hex bytestring provided for '" ++ msg ++ "'. Bytestring provided: '" ++ show bs ++ "'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is a clear upgrade to existing code so totally fine for now, but just a general comment not a great ux to use error
for user facing errors, and this function might be better written to return an Either
(or perhaps we could add some special Error
effect to Effects.hs
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, actually, good point. It should be an Either. I'll rewrite it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have re-written the error handling here to be MUCH better. It's done with Maybe
and we handle the errors at the source when the Nothing
happens, and give very user-friendly error messages, with exitFailure
, etc. @d-xo let me know what you think!
Out of scope for this PR I think but it might be convenient to be able to do |
a1fc1d0
to
89771a2
Compare
57d6e2b
to
e76e4f6
Compare
…dling Also giving example for how to do equivalence checking
e76e4f6
to
f01005c
Compare
Description
As per #581 the error printing was wrong. Furthermore, we should have examples on HOW to paste in text from files. It was not obvious to me how to do it, so we should have at least one example in our handbook.
Checklist