-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use different exit codes for different failures #2243
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ekalin
changed the title
wip: Use different exit codes for different failures
Use different exit codes for different failures
May 8, 2024
I believe this is now ready for review. |
aandergr
reviewed
May 11, 2024
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 an amazing change, it seems well crafted, makes our error handling cleaner and was a pleasure to go through. Thanks! I have only a few minor suggestions/remarks and then this can be merged :)
aandergr
reviewed
May 11, 2024
Exit with 2 when no target was passed and wasn't logged in, and exit with 0 when no target was passed but was logged in (a session was saved).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2220
Here's the general idea of how each situation is handled:
InvalidArgumentException
, which is caught atmain()
.InvalidArgumentException
is also used for other errors, that generally can only be triggered when used as a module. I don't think that's a problem, but another exception could be used specifically for those initialization errors.LoginException
. Some more specific login exceptions were made into subclasses._main
, it just sets a flag with the status to be returned.Some notes:
__main__.py
). But maybe thatexcept
is not necessary: hopefully no exception should reach there, and if it does, maybe letting the program crash (and include the stack trace) is more appropriate.