Class AppianException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.appiancorp.suiteapi.common.exceptions.AppianException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ActionNotFoundException, AppianException, AppianStorageException, ApplicationNotFoundException, Controller.ControllerException, DuplicateExpressionException, DuplicateIdException, DuplicateNameException, DuplicateUuidException, InvalidActionException, InvalidActivityClassSchemaException, InvalidApplicationException, InvalidCalendarException, InvalidDecimalException, InvalidNavigationItemException, InvalidStatusException, LocalizedAppianRuntimeException.LocalizedAppianException, ObjectNotFoundException, RenameNotAllowedException, ResultPageSizeException, RetryableAppianException, SelfRenameException, ServiceLocatorException, SmartServiceException, UnavailableApplicationException, UpgradeException

public class AppianException extends Exception
AppianException is the base class of all application-level exceptions thrown in the product. Application-level exceptions are intended to be caught and handled locally by one of the callers that is capable of taking the appropriate action (such as retrying, performing alternative operations, notifying the user, showing a local message on the user interface, etc.) AppianException takes care of properly formatting and internationalizing the exception messages by associating the exception with an error code. Subclasses should override the getErrorCode and getErrorCodeArguments methods to map the appropriate message to the exception.
See Also:
  • Constructor Details

    • AppianException

      public AppianException(ErrorCode errorCode, Object... errorCodeArgs)
    • AppianException

      public AppianException(ErrorCode errorCode, Throwable cause)
    • AppianException

      public AppianException(ErrorCode errorCode, Throwable cause, Object... errorCodeArgs)
    • AppianException

      @Deprecated public AppianException()
      Deprecated.
      Constructs a new AppianException with an empty string as its detail message.
    • AppianException

      @Deprecated public AppianException(String message)
      Deprecated.
      this constructor will be removed in future releases, as all exception messages must be associated via an error code.
    • AppianException

      public AppianException(Throwable cause)
      Constructs a new AppianException as a wrapper around the Throwable passed in with a detail message of (cause==null ? "" : cause.toString()).
      Parameters:
      cause - the cause, or the Throwable that caused this AppianException to get thrown
    • AppianException

      @Deprecated public AppianException(String message, Throwable cause)
      Deprecated.
      this constructor will be removed in future releases, as all exception messages must be associated via an error code.
  • Method Details

    • getErrorCode

      public ErrorCode getErrorCode()
      Gets the error code associated with this exception. Subclasses should override this method to return specific error codes. The default implementation returns APNX-1-0000-000 (ErrorCode.GENERIC_ERROR).
      See Also:
    • getErrorCodeArguments

      protected Object[] getErrorCodeArguments()
      Gets the arguments that must be used to render this exception's message representation. Subclasses should override this method to return specific arguments. The default implementation returns a length 1 array containing the message as returned by the parent class of AppianException. This method is only called when getErrorCodeArguments(Locale) hasn't been overwritten.
      Returns:
      the arguments of the error code tied to this exception
      See Also:
    • getErrorCodeArgumentsAsStringArray

      public final String[] getErrorCodeArgumentsAsStringArray(Locale locale)
      Returns the arguments (converted to Strings) of the error code tied to this exception. Returns an empty array if there are no arguments.
      Parameters:
      locale - The locale to use for retrieving the arguments.
    • getErrorCodeArguments

      protected Object[] getErrorCodeArguments(Locale locale)
      Gets the arguments that must be used to render this exception's message and title representation. Subclasses should override this method to return specific locale-sensitive arguments. The default implementation calls getErrorCodeArguments().
      Parameters:
      locale - arguments' locale
      Returns:
      the arguments of the error code tied to this exception
    • getMessage

      public String getMessage()
      The default implementation is equivalent to calling getLocalizedMessage()
      Overrides:
      getMessage in class Throwable
    • getLocalizedMessage

      public String getLocalizedMessage()
      The default implementation is equivalent to calling getLocalizedMessage(Locale) with Locale.US as argument. Please note that the error message filtering logic in https://issues.appian.com/browse/AN-274235 depends on this default behavior. Please contact Portals Foundations before changing this default behavior.
      Overrides:
      getLocalizedMessage in class Throwable
    • getLocalizedMessage

      public String getLocalizedMessage(Locale locale)
      Returns this exception's message representation. This method should be used whenever the message is to be displayed to the end user. The default representation does not include any error code information because this may be rendered in different ways across the application. If needed, the exception's error code can be retrieved from getErrorCode().
      Parameters:
      locale - message's locale
      Returns:
      this exception's message representation
      See Also:
    • getLocalizedTitle

      public String getLocalizedTitle(Locale locale)
      Returns this exception's title representation. This method should be used whenever the title is to be displayed to the end user. The default representation does not include any error code information because this may be rendered in different ways across the application. If needed, the exception's error code can be retrieved from getErrorCode().
      Parameters:
      locale - title's locale
      Returns:
      this exception's title representation
      See Also:
    • getLocalizedMessageWithErrorCode

      public String getLocalizedMessageWithErrorCode(Locale locale)
      Returns this exception's default message representation with error code information. This method could be used whenever the message is to be displayed to the end user. Although the default representation getLocalizedMessage(Locale) does not include any error code information, as the representation could vary in different ways across the application, this method provides a utility for a representation with error code. If the error code is null or ErrorCode.GENERIC_ERROR, no error code information is included. Be sure while using this method as the requirements could vary, in which case use getLocalizedMessage(Locale) in conjunction with getErrorCode().
      Parameters:
      locale - message's locale
      Returns:
      this exception's default message representation with error code
      See Also:
    • toString

      public String toString()
      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 by getMessage() and the error code associated with this exception. If the error code is ErrorCode.GENERIC_ERROR, no error code information is included.
      Overrides:
      toString in class Throwable