-
Notifications
You must be signed in to change notification settings - Fork 48
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
base: main
Are you sure you want to change the base?
Conversation
Better documentation, better error printing Related to #581
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! |
@@ -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.
Out of scope for this PR I think but it might be convenient to be able to do |
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