Class Tm1ApiException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Tm1AuthenticationException, Tm1BadRequestException, Tm1ConflictException, Tm1ForbiddenException, Tm1NotFoundException, Tm1NotImplementedException, Tm1PreconditionFailedException, Tm1ServerException

TM1 answered with an error status. Carries the status, the parsed OData error and what it means (kind()). The subclass follows from the kind first and the status second, so a "not found" TM1 reports as a 400 is still a Tm1NotFoundException.
See Also:
  • Constructor Details

    • Tm1ApiException

      protected Tm1ApiException(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url)
      Creates an exception for an error response.
      Parameters:
      status - the HTTP status
      kind - what the error means
      error - the parsed error body, or null
      method - the request's HTTP method
      url - the request's URL, without credentials
  • Method Details

    • of

      public static Tm1ApiException of(int status, @Nullable ODataError error, String method, String url, Tm1ErrorClassifier classifier)
      The exception for an error response, classified with classifier.
      Parameters:
      status - the HTTP status
      error - the parsed error body, or null if the body wasn't an OData error
      method - the request's HTTP method
      url - the request's URL, without credentials
      classifier - works out the error's kind from the status and body
      Returns:
      the subclass matching the kind and status
    • of

      public static Tm1ApiException of(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url)
      The exception for an error response whose kind is already known.
      Parameters:
      status - the HTTP status
      kind - what the error means
      error - the parsed error body, or null if the body wasn't an OData error
      method - the request's HTTP method
      url - the request's URL, without credentials
      Returns:
      the subclass matching the kind first and the status second
    • isRetryable

      public boolean isRetryable()
      True for statuses where trying again later may work: 429, 502, 503 and 504.
      Specified by:
      isRetryable in class Tm1Exception
      Returns:
      true if a retry could succeed
    • mayHaveApplied

      public boolean mayHaveApplied()
      False for client errors (4xx), which TM1 rejected; true for server errors, except 501.
      Specified by:
      mayHaveApplied in class Tm1Exception
      Returns:
      false only if TM1 certainly didn't act on the request
    • status

      public int status()
      The HTTP status.
      Returns:
      the status code, such as 404
    • kind

      public Tm1ErrorKind kind()
      What the error means.
      Returns:
      the kind, never null
    • error

      public @Nullable ODataError error()
      The OData error body, or null if the response didn't have one.
      Returns:
      the error, or null