Class CommandLine.DefaultExceptionHandler
java.lang.Object
org.apache.logging.log4j.core.tools.picocli.CommandLine.DefaultExceptionHandler
- All Implemented Interfaces:
CommandLine.IExceptionHandler
- Enclosing class:
- CommandLine
public static class CommandLine.DefaultExceptionHandler
extends Object
implements CommandLine.IExceptionHandler
Default exception handler that prints the exception message to the specified
PrintStream
, followed by the
usage message for the command or subcommand whose input was invalid.
Implementation roughly looks like this:
System.err.println(paramException.getMessage()); paramException.getCommandLine().usage(System.err);
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhandleException
(CommandLine.ParameterException ex, PrintStream out, CommandLine.Help.Ansi ansi, String... args) Handles aParameterException
that occurred while parsing the command line arguments and optionally returns a list of results.
-
Constructor Details
-
DefaultExceptionHandler
public DefaultExceptionHandler()
-
-
Method Details
-
handleException
public List<Object> handleException(CommandLine.ParameterException ex, PrintStream out, CommandLine.Help.Ansi ansi, String... args) Description copied from interface:CommandLine.IExceptionHandler
Handles aParameterException
that occurred while parsing the command line arguments and optionally returns a list of results.- Specified by:
handleException
in 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
- thePrintStream
to 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
-