Package io.inversion
Class ApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.inversion.ApiException
- All Implemented Interfaces:
Status,Serializable
- See Also:
-
Field Summary
FieldsFields inherited from interface io.inversion.Status
SC_200_OK, SC_201_CREATED, SC_202_ACCEPTED, SC_204_NO_CONTENT, SC_307_TEMPORARY_REDIRECT, SC_308_PERMANENT_REDIRECT, SC_400_BAD_REQUEST, SC_401_UNAUTHORIZED, SC_403_FORBIDDEN, SC_404_NOT_FOUND, SC_409_CONFLICT, SC_429_TOO_MANY_REQUESTS, SC_500_INTERNAL_SERVER_ERROR, SC_501_NOT_IMPLEMENTED, SC_507_INSUFFICIENT_STORAGE, SC_599_NETWORK_CONNECT_TIMEPUT_ERROR -
Constructor Summary
ConstructorsConstructorDescriptionApiException(String messageFormat, Object... args) ApiException(Throwable cause) ApiException(Throwable cause, String httpStatus, String messageFormat, Object... args) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetMessage(Throwable cause, String httpStatus, String messageFormat, Object... args) Constructs a useful error message.intbooleanhasStatus(int... statusCodes) static ApiExceptionstatic ApiExceptionnew400BadRequest(String messageFormat, Object... args) static ApiExceptionnew400BadRequest(Throwable cause) static ApiExceptionnew400BadRequest(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew401Unauthroized(String messageFormat, Object... args) static ApiExceptionnew401Unauthroized(Throwable cause) static ApiExceptionnew401Unauthroized(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew403Forbidden(String messageFormat, Object... args) static ApiExceptionnew403Forbidden(Throwable cause) static ApiExceptionnew403Forbidden(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew404NotFound(String messageFormat, Object... args) static ApiExceptionnew404NotFound(Throwable cause) static ApiExceptionnew404NotFound(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew429TooManyRequests(String messageFormat, Object... args) static ApiExceptionnew429TooManyRequests(Throwable cause) static ApiExceptionnew429TooManyRequests(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew500InternalServerError(String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew500InternalServerError(Throwable cause, String messageFormat, Object... args) static ApiExceptionstatic ApiExceptionnew501NotImplemented(String messageFormat, Object... args) static ApiExceptionnew501NotImplemented(Throwable cause) static ApiExceptionnew501NotImplemented(Throwable cause, String messageFormat, Object... args) static voidThrows a "500 Internal Server Error" ApiException with the given messagestatic voidRethrowscauseas a "500 Internal Server Error" ApiExceptionstatic voidwithStatus(String status) Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
status
-
-
Constructor Details
-
ApiException
- Throws:
ApiException
-
ApiException
- Throws:
ApiException
-
ApiException
- Throws:
ApiException
-
ApiException
public ApiException(Throwable cause, String httpStatus, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
-
Method Details
-
getStatus
-
withStatus
-
hasStatus
public boolean hasStatus(int... statusCodes) -
getStatusCode
public int getStatusCode() -
getMessage
public static String getMessage(Throwable cause, String httpStatus, String messageFormat, Object... args) Constructs a useful error message.All arguments are optional but if everything is null you will get an empty string.
- Parameters:
cause- the cause of the errorhttpStatus- the HTTP stats codde of the errormessageFormat- the caller supplied error message with variable placeholdersargs- variables to insert intomessageFormat- Returns:
- a hopefully user friendly error message
- See Also:
-
Utils.format(String, Object...)
-
throwEx
Rethrowscauseas a "500 Internal Server Error" ApiException- Parameters:
cause- the cause of the error- Throws:
ApiException- always
-
throwEx
Throws a "500 Internal Server Error" ApiException with the given message- Parameters:
messageFormat- the error message potentially with variablesargs- values substituted intomessageFormat- Throws:
ApiException- always
-
throwEx
public static void throwEx(Throwable cause, String status, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new400BadRequest
- Throws:
ApiException
-
new400BadRequest
- Throws:
ApiException
-
new400BadRequest
public static ApiException new400BadRequest(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new400BadRequest
public static ApiException new400BadRequest(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new401Unauthroized
- Throws:
ApiException
-
new401Unauthroized
- Throws:
ApiException
-
new401Unauthroized
public static ApiException new401Unauthroized(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new401Unauthroized
public static ApiException new401Unauthroized(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new403Forbidden
- Throws:
ApiException
-
new403Forbidden
- Throws:
ApiException
-
new403Forbidden
public static ApiException new403Forbidden(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new403Forbidden
public static ApiException new403Forbidden(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new404NotFound
- Throws:
ApiException
-
new404NotFound
- Throws:
ApiException
-
new404NotFound
- Throws:
ApiException
-
new404NotFound
public static ApiException new404NotFound(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new429TooManyRequests
- Throws:
ApiException
-
new429TooManyRequests
- Throws:
ApiException
-
new429TooManyRequests
public static ApiException new429TooManyRequests(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new429TooManyRequests
public static ApiException new429TooManyRequests(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new500InternalServerError
- Throws:
ApiException
-
new500InternalServerError
- Throws:
ApiException
-
new500InternalServerError
public static ApiException new500InternalServerError(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new500InternalServerError
public static ApiException new500InternalServerError(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new501NotImplemented
- Throws:
ApiException
-
new501NotImplemented
- Throws:
ApiException
-
new501NotImplemented
public static ApiException new501NotImplemented(String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new501NotImplemented
public static ApiException new501NotImplemented(Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-