public abstract class BaseServerResponseException extends RuntimeException
HAPI provides a number of subclasses of BaseServerResponseException, and each one corresponds to a specific
HTTP status code. For example, if a IResourceProvider method throws
ResourceNotFoundException, this is a signal to the server that an HTTP 404 should
be returned to the client.
See: A complete list of available exceptions is in the package summary.
If an exception doesn't exist for a condition you want to represent, let us know by filing an
issue in our tracker. You may also
use UnclassifiedServerFailureException to represent any error code you want.
| Constructor and Description |
|---|
BaseServerResponseException(int theStatusCode,
String... theMessages)
Constructor
|
BaseServerResponseException(int theStatusCode,
String theMessage)
Constructor
|
BaseServerResponseException(int theStatusCode,
String theMessage,
IBaseOperationOutcome theBaseOperationOutcome)
Constructor
|
BaseServerResponseException(int theStatusCode,
String theMessage,
Throwable theCause)
Constructor
|
BaseServerResponseException(int theStatusCode,
String theMessage,
Throwable theCause,
IBaseOperationOutcome theBaseOperationOutcome)
Constructor
|
BaseServerResponseException(int theStatusCode,
Throwable theCause)
Constructor
|
BaseServerResponseException(int theStatusCode,
Throwable theCause,
IBaseOperationOutcome theBaseOperationOutcome)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
BaseServerResponseException |
addResponseHeader(String theName,
String theValue)
Add a header which will be added to any responses
|
List<String> |
getAdditionalMessages() |
IBaseOperationOutcome |
getOperationOutcome()
Returns the
IBaseOperationOutcome resource if any which was supplied in the response, or null |
String |
getResponseBody()
In a RESTful client, this method will be populated with the body of the HTTP respone if one was provided by the server, or
null otherwise. |
Map<String,List<String>> |
getResponseHeaders()
Returns a map containing any headers which should be added to the outgoing
response.
|
String |
getResponseMimeType()
In a RESTful client, this method will be populated with the HTTP status code that was returned with the HTTP response.
|
int |
getStatusCode()
Returns the HTTP status code corresponding to this problem
|
boolean |
hasResponseHeaders()
Does the exception have any headers which should be added to the outgoing response?
|
boolean |
isErrorMessageTrusted()
This flag can be used to signal to server infrastructure that the message supplied
to this exception (ie to the constructor) is considered trusted and is safe to
return to the calling client.
|
static BaseServerResponseException |
newInstance(int theStatusCode,
String theMessage) |
BaseServerResponseException |
setErrorMessageTrusted(boolean theErrorMessageTrusted)
This flag can be used to signal to server infrastructure that the message supplied
to this exception (ie to the constructor) is considered trusted and is safe to
return to the calling client.
|
void |
setOperationOutcome(IBaseOperationOutcome theBaseOperationOutcome)
Sets the BaseOperationOutcome resource associated with this exception.
|
void |
setResponseBody(String theResponseBody)
This method is currently only called internally by HAPI, it should not be called by user code.
|
void |
setResponseMimeType(String theResponseMimeType)
This method is currently only called internally by HAPI, it should not be called by user code.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic BaseServerResponseException(int theStatusCode, String theMessage)
theStatusCode - The HTTP status code corresponding to this problemtheMessage - The messagepublic BaseServerResponseException(int theStatusCode, String... theMessages)
theStatusCode - The HTTP status code corresponding to this problemtheMessages - The messagespublic BaseServerResponseException(int theStatusCode, String theMessage, IBaseOperationOutcome theBaseOperationOutcome)
theStatusCode - The HTTP status code corresponding to this problemtheMessage - The messagetheBaseOperationOutcome - An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)public BaseServerResponseException(int theStatusCode, String theMessage, Throwable theCause)
theStatusCode - The HTTP status code corresponding to this problemtheMessage - The messagetheCause - The causepublic BaseServerResponseException(int theStatusCode, String theMessage, Throwable theCause, IBaseOperationOutcome theBaseOperationOutcome)
theStatusCode - The HTTP status code corresponding to this problemtheMessage - The messagetheCause - The underlying cause exceptiontheBaseOperationOutcome - An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)public BaseServerResponseException(int theStatusCode, Throwable theCause)
theStatusCode - The HTTP status code corresponding to this problemtheCause - The underlying cause exceptionpublic BaseServerResponseException(int theStatusCode, Throwable theCause, IBaseOperationOutcome theBaseOperationOutcome)
theStatusCode - The HTTP status code corresponding to this problemtheCause - The underlying cause exceptiontheBaseOperationOutcome - An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)public boolean isErrorMessageTrusted()
public BaseServerResponseException setErrorMessageTrusted(boolean theErrorMessageTrusted)
public BaseServerResponseException addResponseHeader(String theName, String theValue)
theName - The header nametheValue - The header valuethis for easy method chainingpublic List<String> getAdditionalMessages()
public IBaseOperationOutcome getOperationOutcome()
IBaseOperationOutcome resource if any which was supplied in the response, or nullpublic void setOperationOutcome(IBaseOperationOutcome theBaseOperationOutcome)
theBaseOperationOutcome - The BaseOperationOutcome resource Sets the BaseOperationOutcome resource associated with this exception. In server implementations, this is the OperartionOutcome resource to include
with the HTTP response. In client implementations you should not call this method.public String getResponseBody()
null otherwise.
In a restful server, this method is currently ignored.
public void setResponseBody(String theResponseBody)
public Map<String,List<String>> getResponseHeaders()
nullMap<String, String[]> to Map<String, List<String>>public String getResponseMimeType()
In a restful server, this method is currently ignored.
public void setResponseMimeType(String theResponseMimeType)
public int getStatusCode()
public boolean hasResponseHeaders()
getResponseHeaders()public static BaseServerResponseException newInstance(int theStatusCode, String theMessage)
Copyright © 2014–2019 University Health Network. All rights reserved.