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

feat: add lineno at the end of exception string pointing to file #3092

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

bout3fiddy
Copy link
Contributor

What I did

Added lineno at the end of the part of the exception that mentions the contract throwing the error. This is similar to how python does exceptions, for example:

venv/lib/python3.10/site-packages/vyper/semantics/validation/local.py:66: in validate_functions
    err_list.raise_if_not_empty()

The added advantage of this is that it allows IDEs to navigate directly to the line that invokes the exception via cmd+click or ctrl+click (on, for example, VSCode).

How I did it

Just add node.lineno in the exception string where the contract's dir is printed.

How to verify it

you'll need to have a contract that borks. The exception will look something like:

vyper.exceptions.VyperException: Compilation failed with the following errors:
E           
E           StructureException: Value is not callable
E             contract "contracts/SomeExampleContract.vy:1069", function "some_function", line 1069:16 

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Adds line number at the end of exception string. The exceptions format conforms a bit better with how python exceptions are usually printed. An added use-case is that this allows IDEs to offer better code navigation, which improves devex.

Description for the changelog

Adds lineno at the end of exceptions string.

Cute Animal Picture

The most ferocious land animal ... or is it a good boi?

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2022

Codecov Report

Merging #3092 (0038936) into master (593c88f) will decrease coverage by 0.60%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3092      +/-   ##
==========================================
- Coverage   88.34%   87.74%   -0.61%     
==========================================
  Files          98       98              
  Lines       11019    11015       -4     
  Branches     2604     2538      -66     
==========================================
- Hits         9735     9665      -70     
- Misses        833      895      +62     
- Partials      451      455       +4     
Impacted Files Coverage Δ
vyper/exceptions.py 94.59% <100.00%> (ø)
vyper/codegen/arithmetic.py 70.96% <0.00%> (-13.65%) ⬇️
vyper/semantics/types/value/numeric.py 80.45% <0.00%> (-4.60%) ⬇️
vyper/ast/validation.py 75.00% <0.00%> (-4.17%) ⬇️
vyper/ir/s_expressions.py 91.17% <0.00%> (-2.95%) ⬇️
vyper/builtin_functions/functions.py 88.12% <0.00%> (-2.38%) ⬇️
vyper/builtin_functions/convert.py 89.96% <0.00%> (-1.08%) ⬇️
vyper/compiler/phases.py 90.09% <0.00%> (-0.91%) ⬇️
vyper/ast/nodes.py 92.72% <0.00%> (-0.50%) ⬇️
vyper/cli/vyper_json.py 78.67% <0.00%> (-0.35%) ⬇️
... and 4 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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