-
Notifications
You must be signed in to change notification settings - Fork 427
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
Document System.exit usage #1857
Conversation
Resolves #1855 Signed-off-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
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.
I made several suggestions for changes. Can you take a look?
docs/index.adoc
Outdated
The `System.exit` call finishes maven process bypassing the rest of the maven steps including its error handlings. | ||
|
||
In picocli, any exceptions thrown during the `CommandLine.execute` method are captured, printed, and converted to an exit code. | ||
You can check the exit code and perform an appropriate action, such as throwing an exception, instead of calling `System.exit`. |
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 looks strange: you are correct that picocli captures any exceptions thrown during the CommandLine.execute
method. That is the difference with the CommandLine.parseArgs
method. If an application wants to throw an exception when a problem occurs, it should just use parseArgs
.
It would be strange to first capture an exception, convert to an error code, and then use that error code to throw another, less informative, exception...
The manual should not recommend that but instead should recommend using parseArgs
.
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.
changed to recommend parseArgs
and linked to the 9.7. DIY Command Execution
section
Thank you! |
Thank you for the contribution! |
Documentation for a usecase not to use
System.exit
.Resolves #1855