public class SmartServiceException extends AppianException
The Builder
inner class can be used to easily create an exception that has an internationalized message
text based on a key in the bundle file included with the smart service plug-in.
For example, your smart service class may include a method such as the following:
private SmartServiceException createException(Throwable t, String key, Object... args) {
return new SmartServiceException.Builder(getClass(), t).userMessage(key, args).build();
}
and then when the smart service encounters an exception, throw createException(e,"error.my.message")
where
"error.my.message" is a key to an error message defined in the bundle.
AppianSmartService
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
SmartServiceException.Builder
The Builder inner class is used to create an instance of the SmartServiceException.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
addCauseToAlertMessageArgs |
protected boolean |
addCauseToUserMessageArgs |
protected java.lang.Object[] |
alertMessageArgs |
protected java.lang.String |
alertMessageKey |
protected java.lang.Object[] |
userMessageArgs |
protected java.lang.String |
userMessageKey |
Modifier | Constructor and Description |
---|---|
|
SmartServiceException(java.lang.Class<? extends AppianSmartService> smartServiceClass,
java.lang.Throwable cause,
java.lang.String key,
java.lang.Object... args)
Construct a SmartServiceException from all of its constituent parts.
|
|
SmartServiceException(ErrorCode errorCode,
java.lang.Object... errorCodeArgs)
Constructor to be used if the SmartServiceException has an error code associated with it.
|
|
SmartServiceException(ErrorCode errorCode,
java.lang.Throwable cause)
Constructor to be used if the SmartServiceException has an error code associated with it and the root cause of
the exception is to be included.
|
|
SmartServiceException(ErrorCode errorCode,
java.lang.Throwable cause,
java.lang.Object... errorCodeArgs)
Constructor to be used if the SmartServiceException has an error code associated with it and the root cause of
the exception is to be included.
|
protected |
SmartServiceException(SmartServiceException.Builder builder)
Constructor that creates the SmartServiceException based on the Builder inner class.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAlertMessage(java.util.Locale locale)
This method is called by the process execution layer to determine the message that should be shown in the body of
the alert.
|
java.lang.String |
getAttendedUserMessage(java.util.Locale locale)
This method is called by the process execution layer to determine the message that should be shown to the user
in their locale.
|
protected java.lang.String |
getCauseMessage(java.util.Locale locale) |
java.lang.String |
getExceptionClassName()
If the exception that caused this SmartServiceException is set, this method returns the name of that exception
class, otherwise it will return null.
|
protected java.lang.String |
getMessageFromBundle(java.lang.String key,
java.lang.Object[] args,
java.util.Locale locale) |
java.lang.String |
toString()
Returns a detailed exception's message representation.
|
getErrorCode, getErrorCodeArguments, getErrorCodeArguments, getErrorCodeArgumentsAsStringArray, getLocalizedMessage, getLocalizedMessage, getLocalizedMessageWithErrorCode, getLocalizedTitle, getMessage
protected java.lang.String alertMessageKey
protected java.lang.Object[] alertMessageArgs
protected boolean addCauseToAlertMessageArgs
protected java.lang.String userMessageKey
protected java.lang.Object[] userMessageArgs
protected boolean addCauseToUserMessageArgs
public SmartServiceException(ErrorCode errorCode, java.lang.Object... errorCodeArgs)
errorCode
- the error code associated with the exceptionerrorCodeArgs
- the parameters to the error code messageErrorCode
public SmartServiceException(ErrorCode errorCode, java.lang.Throwable cause, java.lang.Object... errorCodeArgs)
errorCode
- the error code associated with the exceptioncause
- the cause of the exceptionerrorCodeArgs
- the parameters to the error code messageErrorCode
public SmartServiceException(ErrorCode errorCode, java.lang.Throwable cause)
errorCode
- the error code associated with the exceptioncause
- the cause of the exceptionErrorCode
public SmartServiceException(java.lang.Class<? extends AppianSmartService> smartServiceClass, java.lang.Throwable cause, java.lang.String key, java.lang.Object... args)
smartServiceClass
- the class that is throwing the exceptioncause
- the Throwable that was caught, causing the SmartServiceException to be thrownkey
- the key to the error message in the bundleargs
- the set of paramaters that are passed with the error message to include dynamic information in the
message if the value of the error bundle contains templates.protected SmartServiceException(SmartServiceException.Builder builder)
Builder.build
method.builder
- the instance of the Builder inner class on which the SmartServiceException should be based.public java.lang.String getAlertMessage(java.util.Locale locale)
public java.lang.String getAttendedUserMessage(java.util.Locale locale)
public java.lang.String getExceptionClassName()
protected java.lang.String getCauseMessage(java.util.Locale locale)
protected java.lang.String getMessageFromBundle(java.lang.String key, java.lang.Object[] args, java.util.Locale locale)
public java.lang.String toString()
AppianException
AppianException.getMessage()
and the error code
associated with this exception. If the error code is
ErrorCode.GENERIC_ERROR
, no error code information is included.toString
in class AppianException
Copyright © 2003-2024 Appian Corporation. All Rights Reserved.