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

Option to have only exception str, but no traceback #247

Closed
ocervell opened this issue Jun 3, 2021 · 2 comments
Closed

Option to have only exception str, but no traceback #247

ocervell opened this issue Jun 3, 2021 · 2 comments

Comments

@ocervell
Copy link

ocervell commented Jun 3, 2021

Seems that adding -e also suppress the exception name and cause. It would be great to keep them while supressing the traceback

Example with Arpeggio library:

Failure in tests.unit.test_promql.TestPromQLConversion.test_conversion (expr='sum by(pod)(rate(metric_test_app[2m] * 60)')
  File "/Users/ocervello/Workspace/dev/cloudops-migrator/tests/unit/test_promql.py", line 39, in test_conversion
    convert_promql_to_mql(expr)

... 1000 lines of traceback

    result = self._parse(parser)
  File "/Users/ocervello/.virtualenvs/cloudops-migrator/lib/python3.8/site-packages/arpeggio/__init__.py", line 370, in _parse
    result = e.parse(parser)
  File "/Users/ocervello/.virtualenvs/cloudops-migrator/lib/python3.8/site-packages/arpeggio/__init__.py", line 789, in parse
    result = self._parse(parser)
  File "/Users/ocervello/.virtualenvs/cloudops-migrator/lib/python3.8/site-packages/arpeggio/__init__.py", line 898, in _parse
    parser._nm_raise(self, c_pos, parser)
  File "/Users/ocervello/.virtualenvs/cloudops-migrator/lib/python3.8/site-packages/arpeggio/__init__.py", line 1718, in _nm_raise
    raise self.nm
arpeggio.NoMatch: Expected '[' or 'offset' or 'by' or '*' or '/' or '+' or '-' or 'or' or '>=' or '<=' or '>' or '<' or '==' or ')' at position (1, 43) => '[2m] * 60)*'.

Running with -e disables everything, but keeping just the last line would be super helpful (the traceback is pretty useless):

arpeggio.NoMatch: Expected '[' or 'offset' or 'by' or '*' or '/' or '+' or '-' or 'or' or '>=' or '<=' or '>' or '<' or '==' or ')' at position (1, 43) => '[2m] * 60)*'.
@CleanCut
Copy link
Owner

CleanCut commented Jun 8, 2021

I wouldn't be opposed to such a feature. If you would like to give it a shot and make a pull request, I would be happy to review it.

You would probably only need to change config.py and result.py and add tests to test/test_config.py and test/test_result.py

Just searching for occurrences of no_tracebacks and doing the same thing with a new option in config.py should be enough to get a new option plumbed in, and then you would need to customize the output logic in result.py.

@CleanCut
Copy link
Owner

Closing due to lack of activity. I'd be happy to review a PR if someone wanted to give this a try, or reopen this issue if there is more to discuss. Otherwise, I'll consider the popular demand for this feature too low to bother with.

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

No branches or pull requests

2 participants