-
Notifications
You must be signed in to change notification settings - Fork 418
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
Custom exception handling for Runnable/Callable #541
Labels
Milestone
Comments
Another option might be to allow annotating the exception. This is what Spring does for MVC error codes |
Can you provide a link? |
Interesting idea, thank you! |
remkop
added a commit
that referenced
this issue
Apr 24, 2019
…te` and `tryExecute` methods: configurable convenience methods with improved exit code support. * The new `execute` and `tryExecute` methods are similar to the `run`, `call` and `invoke` methods, but are not static, so they allow parser configuration. * In addition, these methods, in combination with the new `IExitCodeGenerator` and `IExitCodeExceptionMapper` interfaces, offer clean exit code support. * Finally, the `tryExecute` method rethrows any exception thrown from the Runnable, Callable or Method, while `execute` is guaranteed to never throw an exception. * Many variants of the previous `run`, `call` and `invoke` convenience methods are now deprecated in favor of the new `execute` methods. * Many methods on `AbstractHandler` are now deprecated. Still TODO: tests and documentation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current convenience API doesn’t make it easy to have different exit codes for different exceptions. The most convenient API is to invoke
CommandLine.run(new MyRunnable(), args)
in themain
method, but this doesn’t let you specify an exit code. TheparseWithHandlers
method gives more control but is more clunky and doesn’t allow different exit codes for different exceptions.One idea is to let the Runnable/Callable handle the exception if it implements the
IExceptionHandler2
interface.This interface could potentially be split into two super interfaces
IParameterExceptionHandler
andIExecutionExceptionHandler
to allow applications to handle only some exceptions and use the default exception handler for the rest.Related: #424
The text was updated successfully, but these errors were encountered: