public class AccessException extends Exception implements ErrorInfo
Interceptor to indicate a transaction should
not proceed. Depending on the state of the transaction, this AccessException may cause the transaction to be
stopped. For example, when a RuleInterceptor is evaluated within an "Any"
Ruleset, the failure of one RuleInterceptor may be ignored.
The usual message and cause arguments specify the technical details of the exception, and will not be
presented to an end-user in an HTTP response by default.
An HttpStatus is required when creating an AccessException, and specifies what type of error response
should be generated as a result of the exception. Additionally, an AccessExceptionContext can be used to
specify a localized message that may be included in an error response.
For example, the following will raise an exception that should generate a 403 Forbidden response that contains a message localized for the user's current locale.
try
{
...
}
catch(SomeException e)
{
throw new AccessException(
AccessExceptionContext.create(HttpStatus.FORBIDDEN)
.exceptionMessage("Invalid value: " + value)
.cause(e)
.errorDescription(new BasicLocalizedMessage("invalid.value.msg")));
}
| Constructor and Description |
|---|
AccessException(AccessExceptionContext context)
Constructs a new
AccessException from an AccessExceptionContext. |
AccessException(String message,
HttpStatus status)
Constructs a new
AccessException. |
AccessException(String message,
HttpStatus status,
Throwable cause)
Constructs a new
AccessException. |
| Modifier and Type | Method and Description |
|---|---|
Throwable |
getErrorCause()
Retrieves the
Throwable that caused the error. |
LocalizedMessage |
getErrorMessage()
Retrieves the primary error message to be presented to the end-user in the body of the response, which may be
localized for the current locale.
|
HttpStatus |
getErrorStatus()
Retrieves the response status, which encapsulates both the status code (e.g.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic AccessException(String message, HttpStatus status, Throwable cause)
AccessException.message - the exception message, for retrieval by Throwable.getMessage()status - the HTTP error response status, for retrieval by getErrorStatus()cause - the exception cause, for retrieval by Throwable.getCause() (optional, may be null)public AccessException(String message, HttpStatus status)
AccessException.message - the exception message, for retrieval by Throwable.getMessage()status - the HTTP error response status, for retrieval by getErrorStatus()public AccessException(AccessExceptionContext context)
AccessException from an AccessExceptionContext.context - the source of the error informationpublic HttpStatus getErrorStatus()
ErrorInfogetErrorStatus in interface ErrorInfopublic LocalizedMessage getErrorMessage()
ErrorInfogetErrorMessage in interface ErrorInfopublic Throwable getErrorCause()
ErrorInfoThrowable that caused the error.getErrorCause in interface ErrorInfoCopyright 2023 Ping Identity Corp. All rights reserved.