Class CDAHttpException

  • All Implemented Interfaces:
    java.io.Serializable

    public class CDAHttpException
    extends java.lang.RuntimeException
    This class will represent known Contentful exceptions
    See Also:
    Serialized Form
    • Constructor Detail

      • CDAHttpException

        public CDAHttpException​(okhttp3.Request request,
                                okhttp3.Response response)
        Construct an error response.

        This constructor will fill the exception with easy accessible values, like responseCode(). responseMessage(), but also rateLimitReset().

        Parameters:
        request - the request issuing the error.
        response - the response from the server to this faulty request.
    • Method Detail

      • toString

        public java.lang.String toString()
        Convert exception to human readable form.
        Overrides:
        toString in class java.lang.Throwable
        Returns:
        a string representing this exception.
      • responseCode

        public int responseCode()
        Returns:
        the response code of the request.
      • responseMessage

        public java.lang.String responseMessage()
        Returns:
        the message the server returned.
      • responseBody

        public java.lang.String responseBody()
        Returns:
        the errors body, potentially containing more information.
      • rateLimitHourLimit

        public int rateLimitHourLimit()
        Returns:
        the hourly rate limit or -1 if header not send
      • rateLimitHourRemaining

        public int rateLimitHourRemaining()
        Returns:
        the number of remaining requests that can be made for the current hour or -1 if header not send
      • rateLimitSecondLimit

        public int rateLimitSecondLimit()
        Returns:
        the per second rate limit or -1 if header not send
      • rateLimitSecondRemaining

        public int rateLimitSecondRemaining()
        Returns:
        the number of remaining requests that can be made per second or -1 if header not send
      • rateLimitReset

        public int rateLimitReset()
        Returns:
        the number of seconds until the user can make their next request or -1 if header not send