-
Notifications
You must be signed in to change notification settings - Fork 5
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
Print error messages not stacktraces #140
Conversation
Add bcftools validation tests for error conditions.
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.
Great approach, but I think it's too broad at the moment and will prevent bugs from getting reported. I don't want to close #139 until we stop abusing assert
for UI purposes.
Ideally we'd have our own exception class hierarchy which would let us precisely state which exceptions we think are things that should get reported to the user as an input error, but that's a lot of work.
vcztools/cli.py
Outdated
def wrapper(*args, **kwargs): | ||
try: | ||
return func(*args, **kwargs) | ||
except Exception as e: |
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 is a good approach, but I think we should stack trace when unexpected exceptions happen. Perhaps we could catch ValueErrors here instead, which would probably get most of the actual interface errors we expect?
In particular, we should check to see if it's already a ClickException and just reraise if so. Otherwise we're losing a bunch of subtlety.
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.
Also - nice usage of functools.wraps!!!
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 is a good approach, but I think we should stack trace when unexpected exceptions happen. Perhaps we could catch ValueErrors here instead, which would probably get most of the actual interface errors we expect?
Done.
I totally agree. I had a quick look at where we have There was one |
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.
LGTM!
Created #141 to track dealing with IO errors, which should be straightforward. |
Fixes #137
I haven't tried to harmonise the error messages or exit codes (#117) here - just looking for a string "Error:" and a non-zero exit code.