Package net.commuty.parking.http
Class HttpRequestException
java.lang.Object
java.lang.Throwable
java.lang.Exception
net.commuty.parking.http.ApiException
net.commuty.parking.http.HttpRequestException
- All Implemented Interfaces:
Serializable
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:
isForbidden(): http status 403isUnauthorized(): http status 401isBadRequest(): http status 400
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:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpRequestException(int httpResponseCode, Error errorResponse) -
Method Summary
Modifier and TypeMethodDescriptionReturns more information linked with the request exception.intReturns the http status code.booleanIndicates if the request is a bad request (http 400).booleanIndicates if the request is forbidden (http 403).booleanIndicates 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
-
Constructor Details
-
HttpRequestException
-
-
Method Details
-
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.
-