Suppress click stacktrace in case of invalid cli option (#2854)#2915
Suppress click stacktrace in case of invalid cli option (#2854)#2915cdeler wants to merge 6 commits intopython-poetry:masterfrom
Conversation
80a7e72 to
049efdc
Compare
abn
left a comment
There was a problem hiding this comment.
Apologies for the delay. Looks good in general, couple of comments.
| # according to https://www.python.org/dev/peps/pep-0415/ | ||
| # raise ... from ... overrides __cause__, so do it manually | ||
| # it should be replaced by raise PoetryException(str(ex)) from None | ||
| # as soon as python2.7 has been dropped |
| from poetry.exceptions import PoetryException | ||
|
|
||
|
|
||
| def test_overwrite_exception_in_case_of_invalid_command(app): |
There was a problem hiding this comment.
Any chance we can add a fil ltest to validate the io output does not contain the stack trace?
There was a problem hiding this comment.
I can add this check, but from my point of view it makes the test fragile.
I can check that the exception has ex.__cause__ is None. For us it means that the exception doesn't contain the original stacktrace from click
UPD well, we can check that all stacktrace belongs to poetry
| resolved_command = application.resolve_command(args) | ||
| try: | ||
| resolved_command = application.resolve_command(args) | ||
| except NoSuchOptionException as ex: |
There was a problem hiding this comment.
Should we expand to this to all similar exceptions?
There was a problem hiding this comment.
Do you mean that I should catch bare Exception there? I didn't find any root CliKit exception, which I can catch there (but well, I can catch RuntimeError)
049efdc to
9933cd0
Compare
3184032 to
10b2112
Compare
10b2112 to
dfc5a2b
Compare
|
@cdeler apologies this has not received the attention it needs. Is this something you still want to look at? |
|
IMO, this is still way too verbose, but now it also tells much less about what's happened, so it makes it difficult to understand the nature of error in case it's needed. I think poetry should output only error message by default, and output full stack trace if being asked with Upd. I dug a bit more and realised this really silence exceptions only upon resolving a command,
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #2854
After the fix, the stacktrace looks the different: