Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

msooseth
Copy link
Collaborator

@msooseth msooseth commented Oct 7, 2024

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

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

Better documentation, better error printing

Related to #581
@msooseth msooseth requested a review from blishko October 7, 2024 12:39
@charles-cooper
Copy link

looks good, although maybe this should be a validation error instead of an internal error?

@msooseth
Copy link
Collaborator Author

msooseth commented Oct 7, 2024

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 ++ "'"
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@charles-cooper
Copy link

Out of scope for this PR I think but it might be convenient to be able to do hevm equivalence a.txt b.txt (and maybe even more than two files!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants