public class ResponseException extends Exception
As a developer, it's still useful to be able to use try-catch blocks, even if the catch block converts
the ResponseException
to a Promise<Response, ...>
.
Note that this is a convenience class offered by the HTTP Framework, there is no requirement to use it in Filter or Handler implementations:
Response
that may be used to forward an error message without losing detailed
information about the cause of the failureResponse
may be automatically associated to this exception in order to keep track of the
original failureResponse.getCause()
,
Serialized FormConstructor and Description |
---|
ResponseException(Response response)
Constructs a ResponseException using the given
response . |
ResponseException(Response response,
String message,
Throwable cause)
Constructs a ResponseException using the given
response , message and parent cause . |
ResponseException(String message)
Constructs a ResponseException using the given
message . |
ResponseException(String message,
Throwable cause)
Constructs a ResponseException using the given
message and parent cause . |
Modifier and Type | Method and Description |
---|---|
Response |
getResponse()
Returns the response associated to this exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public ResponseException(String message)
message
.message
- Error messagepublic ResponseException(Response response)
response
.
The provided Response won't be linked to this exception.response
- ResponseResponse.setCause(Exception)
,
ResponseException.getResponse()
public ResponseException(String message, Throwable cause)
message
and parent cause
.
This constructor also build a Response
object that will be linked to this exception instance.message
- Error messagecause
- Error causepublic ResponseException(Response response, String message, Throwable cause)
response
, message
and parent cause
.
The provided Response won't be linked to this exception.response
- response objectmessage
- Error messagecause
- Error causepublic Response getResponse()
try {
doSomeStuff(request);
} catch (ResponseException e) {
return Promises.newResultPromise(e.getResponse());
}
It can also be used as an informal pointer to the message that caused the exception (Client API usage)
Copyright © 2010-2018, ForgeRock All Rights Reserved.