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 java.lang.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 java.util.List<java.lang.Object>handleException(CommandLine.ParameterException ex, java.io.PrintStream out, CommandLine.Help.Ansi ansi, java.lang.String... args)Handles aParameterExceptionthat occurred while parsing the command line arguments and optionally returns a list of results.
-
-
-
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)
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
-
-