Class ApiResponseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
de.saibotk.jmaw.ApiResponseException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TooManyRequestsException

public class ApiResponseException extends Exception
This represents an API exception, for example when the server responds with an HTTP 400 message. The instance will yield the response associated with the exception.
Since:
1.0
See Also:
  • Field Details

    • response

      public final transient retrofit2.Response response
  • Method Details

    • getStatusCode

      public int getStatusCode()
      This will yield the HTTP status code for the associated response.
      Returns:
      the status code.
      Since:
      1.0
    • getErrorBody

      public okhttp3.ResponseBody getErrorBody()
      This will yield the error body from the response.
      Returns:
      the error body.
      Since:
      1.0
    • getApiError

      public Optional<ApiError> getApiError()
      Returns the API's response parsed as a ApiError object, if it contains the typical error and errorMessage fields.
      Returns:
      the parsed ApiError object.
      Since:
      1.0