Package picocli
Class CommandLine.DefaultExceptionHandler<R>
- java.lang.Object
-
- picocli.CommandLine.AbstractHandler<R,CommandLine.DefaultExceptionHandler<R>>
-
- picocli.CommandLine.DefaultExceptionHandler<R>
-
- All Implemented Interfaces:
CommandLine.IExceptionHandler,CommandLine.IExceptionHandler2<R>
- Enclosing class:
- CommandLine
@Deprecated public static class CommandLine.DefaultExceptionHandler<R> extends CommandLine.AbstractHandler<R,CommandLine.DefaultExceptionHandler<R>> implements CommandLine.IExceptionHandler, CommandLine.IExceptionHandler2<R>
Deprecated.Default exception handler that handles invalid user input by printing the exception message, followed by the usage message for the command or subcommand whose input was invalid.ParameterExceptions(invalid user input) is handled like this:err().println(paramException.getMessage()); paramException.getCommandLine().usage(err(), ansi()); if (hasExitCode()) System.exit(exitCode()); else return returnValue;ExecutionExceptionsthat occurred while executing theRunnableorCallablecommand are simply rethrown and not handled.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description DefaultExceptionHandler()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.List<java.lang.Object>handleException(CommandLine.ParameterException ex, java.io.PrintStream out, CommandLine.Help.Ansi ansi, java.lang.String... args)Deprecated.Handles aParameterExceptionthat occurred while parsing the command line arguments and optionally returns a list of results.RhandleExecutionException(CommandLine.ExecutionException ex, CommandLine.ParseResult parseResult)Deprecated.This implementation always simply rethrows the specified exception.RhandleParseException(CommandLine.ParameterException ex, java.lang.String[] args)Deprecated.Prints the message of the specified exception, followed by the usage message for the command or subcommand whose input was invalid, to the stream returned byCommandLine.AbstractHandler.err().protected CommandLine.DefaultExceptionHandler<R>self()Deprecated.Returnsthisto allow method chaining when calling the setters for a fluent API.-
Methods inherited from class picocli.CommandLine.AbstractHandler
andExit, ansi, colorScheme, err, exit, exitCode, hasExitCode, out, returnResultOrExit, throwOrExit, useAnsi, useErr, useOut
-
-
-
-
Method Detail
-
handleException
public java.util.List<java.lang.Object> handleException(CommandLine.ParameterException ex, java.io.PrintStream out, CommandLine.Help.Ansi ansi, java.lang.String... args)
Deprecated.Description copied from interface:CommandLine.IExceptionHandlerHandles aParameterExceptionthat occurred while parsing the command line arguments and optionally returns a list of results.- Specified by:
handleExceptionin interfaceCommandLine.IExceptionHandler- Parameters:
ex- the ParameterException describing the problem that occurred while parsing the command line arguments, and the CommandLine representing the command or subcommand whose input was invalidout- thePrintStreamto print help to if requestedansi- for printing help messages using ANSI styles and colorsargs- the command line arguments that could not be parsed- Returns:
- a list of results, or an empty list if there are no results
-
handleParseException
public R handleParseException(CommandLine.ParameterException ex, java.lang.String[] args)
Deprecated.Prints the message of the specified exception, followed by the usage message for the command or subcommand whose input was invalid, to the stream returned byCommandLine.AbstractHandler.err().- Specified by:
handleParseExceptionin interfaceCommandLine.IExceptionHandler2<R>- Parameters:
ex- the ParameterException describing the problem that occurred while parsing the command line arguments, and the CommandLine representing the command or subcommand whose input was invalidargs- the command line arguments that could not be parsed- Returns:
- the empty list
- Since:
- 3.0
-
handleExecutionException
public R handleExecutionException(CommandLine.ExecutionException ex, CommandLine.ParseResult parseResult)
Deprecated.This implementation always simply rethrows the specified exception.- Specified by:
handleExecutionExceptionin interfaceCommandLine.IExceptionHandler2<R>- Parameters:
ex- the ExecutionException describing the problem that occurred while executing theRunnableorCallablecommandparseResult- the result of parsing the command line arguments- Returns:
- nothing: this method always rethrows the specified exception
- Throws:
CommandLine.ExecutionException- always rethrows the specified exception- Since:
- 3.0
-
self
protected CommandLine.DefaultExceptionHandler<R> self()
Deprecated.Description copied from class:CommandLine.AbstractHandlerReturnsthisto allow method chaining when calling the setters for a fluent API.- Specified by:
selfin classCommandLine.AbstractHandler<R,CommandLine.DefaultExceptionHandler<R>>
-
-