Class HttpRequestException

java.lang.Object
java.lang.Throwable
java.lang.Exception
net.commuty.parking.http.ApiException
net.commuty.parking.http.HttpRequestException
All Implemented Interfaces:
java.io.Serializable

public class HttpRequestException
extends ApiException

This exception will occur when the api accepted the request but returned a HTTP status 400 or above.

You can get the HTTP status code via getHttpResponseCode(). Some helpers methods are present to handle some cases:

Sometimes, you will get more information via the getErrorResponse() method. This exposes a reason and message property. For more information, consult the api documentation.

See Also:
Serialized Form
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected HttpRequestException​(int httpResponseCode, Error errorResponse)  
  • Method Summary

    Modifier and Type Method Description
    Error getErrorResponse()
    Returns more information linked with the request exception.
    int getHttpResponseCode()
    Returns the http status code.
    boolean isBadRequest()
    Indicates if the request is a bad request (http 400).
    boolean isForbidden()
    Indicates if the request is forbidden (http 403).
    boolean isUnauthorized()
    Indicates if the request is unauthorized (http 401).

    Methods inherited from class java.lang.Throwable

    addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • getErrorResponse

      public Error getErrorResponse()
      Returns more information linked with the request exception. Can be null.
    • isForbidden

      public boolean isForbidden()
      Indicates if the request is forbidden (http 403).
    • isUnauthorized

      public boolean isUnauthorized()
      Indicates if the request is unauthorized (http 401).
    • isBadRequest

      public boolean isBadRequest()
      Indicates if the request is a bad request (http 400).
    • getHttpResponseCode

      public int getHttpResponseCode()
      Returns the http status code.