public class UserError extends Throwable
Such errors should be user-correctable, provided the message is clear. So no stack traces should be displayed when UserErrors are thrown.
Constructor and Description |
---|
UserError(String message) |
UserError(String message,
Throwable cause) |
UserError(Throwable cause) |
Modifier and Type | Method and 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.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public UserError(String message)
public UserError(Throwable cause)
public static UserError formatUserError(String message, String... args)
message
- the message string, presumably containing argument placeholdersargs
- 0 or more arguments for substitution for the placeholders in the message stringpublic void setUsage(String usage)
showUsage
- the new settingpublic void displayAndExit()
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.
public String messageForGUIDisplay()
Copyright © 2021. All rights reserved.