public abstract class TranslatableException extends Exception
Modifier and Type | Field and Description |
---|---|
protected int |
code |
protected Object[] |
messageParams |
Constructor and Description |
---|
TranslatableException(int code,
String message)
Create a new exception instance
|
TranslatableException(int code,
String message,
Object[] messageParams)
Creates a new exception instance
|
Modifier and Type | Method and Description |
---|---|
int |
getCode()
Retrieve the error code associated with this exception
|
String |
getLocalizedMessage()
Return the message to show to the user.
|
String |
getMessageKey()
Retrieves the message key that the i18n message will be keyed by.
|
Object[] |
getMessageParameters()
Retrieves the message parameters, if any, that will be used to populate any dynamic message parameters.
|
String |
toString()
Cause the message passed to the constructor to show up on stack trace logs
|
addSuppressed, fillInStackTrace, getCause, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
protected int code
protected Object[] messageParams
public TranslatableException(int code, String message)
code
- an integer code that represents this exception statemessage
- the message that will be posted to stack traces on the console (not necessarily intended for the user)public TranslatableException(int code, String message, Object[] messageParams)
code
- an integer code that represents this exception statemessage
- the message that will be posted to stack traces on the console (not necessarily intended for the user)messageParams
- An array of objects that may be used to dymanically populate a messagepublic int getCode()
public String getMessageKey()
public Object[] getMessageParameters()
public String getLocalizedMessage()
Return the message to show to the user. The framework will first look in the localized property bundles for any messages that match the supplied error code and exception type. If not found, the regular message submitted to the constructor will be returned.
Message bundle properties have the following format:
[simple class name of exception]_[integer error code]=[localized message for this exception and code]
getLocalizedMessage
in class Throwable
Copyright © 2022. All rights reserved.