Class UserError
- java.lang.Object
-
- java.lang.Throwable
-
- org.glassfish.appclient.client.acc.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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
displayAndExit()
Displays the user error message, and any messages along the exception chain, if any, and then exits.static UserError
formatUserError(String message, String... args)
Creates a new UserError instance having formatted the message with the arguments provided.String
messageForGUIDisplay()
void
setUsage(String usage)
Sets whether or not the usage message should be displayed after the error message is displayed to the user.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Method Detail
-
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 placeholdersargs
- 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:
showUsage
- 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()
-
-