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 specifiedPrintStream
, 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 Constructor Description DefaultExceptionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Object>
handleException(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.
-
-
-
Method Detail
-
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
-
-