java.lang.Object
java.lang.Throwable
org.glassfish.embeddable.client.UserError
All Implemented Interfaces:
Serializable

public class UserError extends Throwable
Represents any user error, such as an invalid combination of command options, or specifying a non-existent JAR file.

Such errors should be user-correctable, provided the message is clear. So no stack traces should be displayed when UserErrors are thrown.

Author:
tjquinn
See Also:
  • Constructor Details

    • UserError

      public UserError(String message)
    • UserError

      public UserError(String message, Throwable cause)
    • UserError

      public UserError(Throwable cause)
  • Method Details

    • formatUserError

      public static UserError formatUserError(String message, String... args)
      Creates a new UserError instance having formatted the message with the arguments provided.
      Parameters:
      message - the message string, presumably containing argument placeholders
      args - 0 or more arguments for substitution for the placeholders in the message string
      Returns:
      new UserError with message formatted as requested
    • setUsage

      public void setUsage(String usage)
      Sets whether or not the usage message should be displayed after the error message is displayed to the user.
      Parameters:
      usage - the new setting
    • displayAndExit

      public void displayAndExit()
      Displays the user error message, and any messages along the exception chain, if any, and then exits. If showUsage has been set to true, then the usage message is displayed before exiting.

      Only the messages, and not the stack traces, are shown because these are user errors that should be user-correctable. Stack traces are too alarming and of minimal use to the user as he or she tries to understand and fix the error.

    • messageForGUIDisplay

      public String messageForGUIDisplay()