java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.cruk.clarity.api.ClarityException
- All Implemented Interfaces:
Serializable
Exception decoded when a response from an API call gives an exception
object. The fields from the unmarshalled object are transferred into
one of these, which is then thrown.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected String
protected HttpStatus
protected String
-
Constructor Summary
ConstructorDescriptionInitialise from the given API exception.ClarityException
(Exception ge, HttpStatus httpStatus) Initialise from the given API exception with an HTTP status code. -
Method Summary
Modifier and TypeMethodDescriptionGet the error category.getCode()
Get the error code.Get the HTTP status code.Get the "suggested actions" text.boolean
Convenience method to test whether this exception is because something is not found.void
setHttpStatus
(HttpStatus httpStatus) Set the HTTP status code.void
Convenience method absorb this exception if it is because something is not found, otherwise rethrow itself.toString()
Provide a printable representation of this exception.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
suggestedActions
-
category
-
code
-
httpStatus
-
-
Constructor Details
-
ClarityException
Initialise from the given API exception.- Parameters:
ge
- The Exception unmarshalled from the XML response.
-
ClarityException
Initialise from the given API exception with an HTTP status code.- Parameters:
ge
- The Exception unmarshalled from the XML response.httpStatus
- The return code from the HTTP call.
-
-
Method Details
-
getSuggestedActions
Get the "suggested actions" text.- Returns:
- The suggested actions text.
-
getCategory
Get the error category.- Returns:
- The error category.
-
getCode
Get the error code.- Returns:
- The error code.
-
getHttpStatus
Get the HTTP status code.- Returns:
- The HTTP status code returned from the server.
-
setHttpStatus
Set the HTTP status code.- Parameters:
httpStatus
- The HTTP status code.
-
isNotFound
public boolean isNotFound()Convenience method to test whether this exception is because something is not found.- Returns:
- true if the status is not found (HTTP 404), false otherwise.
- Since:
- 2.27.4
-
throwUnlessNotFound
public void throwUnlessNotFound()Convenience method absorb this exception if it is because something is not found, otherwise rethrow itself. This is designed to be used inside catch blocks where it is possible to ask for an entity by id and handle it not being there (so a speculative GET).- Throws:
ClarityException
- (this) if the reason for this exception is for any reason other than something not being found.- Since:
- 2.27.4
-
toString
Provide a printable representation of this exception. Prints the main error message and, if present, the HTTP status code and the suggested actions.
-