Class ClarityException

All Implemented Interfaces:
Serializable

public class ClarityException extends RuntimeException
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 Details

    • suggestedActions

      protected String suggestedActions
    • category

      protected String category
    • code

      protected String code
    • httpStatus

      protected HttpStatus httpStatus
  • Constructor Details

    • ClarityException

      public ClarityException(Exception ge)
      Initialise from the given API exception.
      Parameters:
      ge - The Exception unmarshalled from the XML response.
    • ClarityException

      public ClarityException(Exception ge, HttpStatus httpStatus)
      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

      public String getSuggestedActions()
      Get the "suggested actions" text.
      Returns:
      The suggested actions text.
    • getCategory

      public String getCategory()
      Get the error category.
      Returns:
      The error category.
    • getCode

      public String getCode()
      Get the error code.
      Returns:
      The error code.
    • getHttpStatus

      public HttpStatus getHttpStatus()
      Get the HTTP status code.
      Returns:
      The HTTP status code returned from the server.
    • setHttpStatus

      public void setHttpStatus(HttpStatus httpStatus)
      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

      public String toString()
      Provide a printable representation of this exception. Prints the main error message and, if present, the HTTP status code and the suggested actions.
      Overrides:
      toString in class Throwable
      Returns:
      A printable string for this exception.