Class TranslatableException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.broadleafcommerce.common.exception.TranslatableException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MVELTranslationException
An exception whose message can be translated into a message suitable for a user.
- Author:
- Jeff Fischer
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTranslatableException
(int code, String message) Create a new exception instanceTranslatableException
(int code, String message, Object[] messageParams) Creates a new exception instance -
Method Summary
Modifier and TypeMethodDescriptionint
getCode()
Retrieve the error code associated with this exceptionReturn the message to show to the user.Retrieves the message key that the i18n message will be keyed by.Object[]
Retrieves the message parameters, if any, that will be used to populate any dynamic message parameters.toString()
Cause the message passed to the constructor to show up on stack trace logsMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
code
protected int code -
messageParams
-
-
Constructor Details
-
TranslatableException
Create a new exception instance- Parameters:
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)
-
TranslatableException
Creates a new exception instance- Parameters:
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 message
-
-
Method Details
-
getCode
public int getCode()Retrieve the error code associated with this exception- Returns:
- the error code
-
getMessageKey
Retrieves the message key that the i18n message will be keyed by.- Returns:
-
getMessageParameters
Retrieves the message parameters, if any, that will be used to populate any dynamic message parameters.- Returns:
-
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]
- Overrides:
getLocalizedMessage
in classThrowable
- Returns:
- The error message to display to the user
-
toString
Cause the message passed to the constructor to show up on stack trace logs
-