Package org.forgerock.http.protocol
Class ResponseException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- org.forgerock.http.protocol.ResponseException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
UmaException
public class ResponseException extends Exception
An HTTP Framework Exception that can be used by filters/handlers to simplify control-flow inside async call-backs.As a developer, it's still useful to be able to use try-catch blocks, even if the catch block converts the
ResponseException
to aPromise<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:
- Ease control-flow inside async call-backs or in synchronous code
- Contains a
Response
that may be used to forward an error message without losing detailed information about the cause of the failure - Contained
Response
may be automatically associated to this exception in order to keep track of the original failure
- See Also:
Response.getCause()
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResponseException(String message)
Constructs a ResponseException using the givenmessage
.ResponseException(String message, Throwable cause)
Constructs a ResponseException using the givenmessage
and parentcause
.ResponseException(Response response)
Constructs a ResponseException using the givenresponse
.ResponseException(Response response, String message, Throwable cause)
Constructs a ResponseException using the givenresponse
,message
and parentcause
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Response
getResponse()
Returns the response associated to this exception.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
ResponseException
public ResponseException(String message)
Constructs a ResponseException using the givenmessage
.- Parameters:
message
- Error message
-
ResponseException
public ResponseException(Response response)
Constructs a ResponseException using the givenresponse
. The provided Response won't be linked to this exception.- Parameters:
response
- Response- See Also:
Response.setCause(Exception)
,getResponse()
-
ResponseException
public ResponseException(String message, Throwable cause)
Constructs a ResponseException using the givenmessage
and parentcause
. This constructor also build aResponse
object that will be linked to this exception instance.- Parameters:
message
- Error messagecause
- Error cause
-
ResponseException
public ResponseException(Response response, String message, Throwable cause)
Constructs a ResponseException using the givenresponse
,message
and parentcause
. The provided Response won't be linked to this exception.- Parameters:
response
- response objectmessage
- Error messagecause
- Error cause
-
-
Method Detail
-
getResponse
public Response getResponse()
Returns the response associated to this exception. It is intended to be used when propagating a specific Response message (constructed at the point where the original error occurred) in try-catch blocks: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)
- Returns:
- the response linked to this exception.
-
-