Class SmartServiceException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.appiancorp.suiteapi.common.exceptions.AppianException
com.appiancorp.suiteapi.process.exceptions.SmartServiceException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
RetryableSmartServiceException
An exception thrown by a smart service in the course of its execution. Throwing this exception is the mechanism by
which a smart service alerts the process execution engine that the node has failed to complete successfully. The
execution layer is then responsible for taking the appropriate action (pausing the node by exception, displaying an
error message, sending an alert, etc.).
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.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The Builder inner class is used to create an instance of the SmartServiceException. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionSmartServiceException
(ErrorCode errorCode, Object... errorCodeArgs) Constructor to be used if the SmartServiceException has an error code associated with it.SmartServiceException
(ErrorCode errorCode, 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, Throwable cause, 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
Constructor that creates the SmartServiceException based on the Builder inner class.SmartServiceException
(Class<? extends AppianSmartService> smartServiceClass, Throwable cause, String key, Object... args) Construct a SmartServiceException from all of its constituent parts. -
Method Summary
Modifier and TypeMethodDescriptiongetAlertMessage
(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.getAttendedUserMessage
(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 String
getCauseMessage
(Locale locale) If the exception that caused this SmartServiceException is set, this method returns the name of that exception class, otherwise it will return null.protected String
getMessageFromBundle
(String key, Object[] args, Locale locale) toString()
Returns a detailed exception's message representation.Methods inherited from class com.appiancorp.suiteapi.common.exceptions.AppianException
getErrorCode, getErrorCodeArguments, getErrorCodeArguments, getErrorCodeArgumentsAsStringArray, getLocalizedMessage, getLocalizedMessage, getLocalizedMessageWithErrorCode, getLocalizedTitle, getMessage
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
alertMessageKey
-
alertMessageArgs
-
addCauseToAlertMessageArgs
protected boolean addCauseToAlertMessageArgs -
userMessageKey
-
userMessageArgs
-
addCauseToUserMessageArgs
protected boolean addCauseToUserMessageArgs
-
-
Constructor Details
-
SmartServiceException
Constructor to be used if the SmartServiceException has an error code associated with it.- Parameters:
errorCode
- the error code associated with the exceptionerrorCodeArgs
- the parameters to the error code message- See Also:
-
SmartServiceException
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.- Parameters:
errorCode
- the error code associated with the exceptioncause
- the cause of the exceptionerrorCodeArgs
- the parameters to the error code message- See Also:
-
SmartServiceException
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.- Parameters:
errorCode
- the error code associated with the exceptioncause
- the cause of the exception- See Also:
-
SmartServiceException
public SmartServiceException(Class<? extends AppianSmartService> smartServiceClass, Throwable cause, String key, Object... args) Construct a SmartServiceException from all of its constituent parts. It's recommended to use the Builder inner class instead of this constructor.- Parameters:
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.
-
SmartServiceException
Constructor that creates the SmartServiceException based on the Builder inner class. Instead of passing a Builder to this constructor use theBuilder.build
method.- Parameters:
builder
- the instance of the Builder inner class on which the SmartServiceException should be based.
-
-
Method Details
-
getAlertMessage
This method is called by the process execution layer to determine the message that should be shown in the body of the alert. If no message is defined for the preferred locale, it falls back to US.- Returns:
- the text of the error message intended for the user
-
getAttendedUserMessage
This method is called by the process execution layer to determine the message that should be shown to the user in their locale. If no message is defined for their preferred locale, it falls back to US.- Returns:
- the text of the error message intended for the user
-
getExceptionClassName
If the exception that caused this SmartServiceException is set, this method returns the name of that exception class, otherwise it will return null.- Returns:
- the name of the exception or null
-
getCauseMessage
-
getMessageFromBundle
-
toString
Description copied from class:AppianException
Returns a detailed exception's message representation. This method should not be used to display messages to the end user. The default representation includes the exception class name, the exception's message as returned byAppianException.getMessage()
and the error code associated with this exception. If the error code isErrorCode.GENERIC_ERROR
, no error code information is included.- Overrides:
toString
in classAppianException
-