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 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 a ParameterException that occurred while parsing the command line arguments and optionally returns a list of results.
      Specified by:
      handleException in interface CommandLine.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 invalid
      out - the PrintStream to print help to if requested
      ansi - for printing help messages using ANSI styles and colors
      args - the command line arguments that could not be parsed
      Returns:
      a list of results, or an empty list if there are no results