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_204_NO_CONTENT, SC_308_PERMANENT_REDIRECT, SC_400_BAD_REQUEST, SC_401_UNAUTHORIZED, SC_403_FORBIDDEN, SC_404_NOT_FOUND, SC_429_TOO_MANY_REQUESTS, SC_500_INTERNAL_SERVER_ERROR, SC_501_NOT_IMPLEMENTED -
Constructor Summary
ConstructorsConstructorDescriptionApiException(String httpStatus) ApiException(String messageFormat, Object... args) ApiException(String httpStatus, Throwable cause, String messageFormat, Object... args) ApiException(Throwable cause) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetMessage(String httpStatus, Throwable cause, String messageFormat, Object... args) Constructs a useful error message.booleanhasStatus(int... statusCodes) static ApiExceptionstatic ApiExceptionnew400BadRequest(String messageFormat, Object... messages) static ApiExceptionnew400BadRequest(Throwable cause) static ApiExceptionnew400BadRequest(Throwable cause, String messageFormat, Object... messages) static ApiExceptionstatic ApiExceptionnew401Unauthroized(String messageFormat, Object... messages) static ApiExceptionnew401Unauthroized(Throwable cause) static ApiExceptionnew401Unauthroized(Throwable cause, String messageFormat, Object... messages) static ApiExceptionstatic ApiExceptionnew403Forbidden(String messageFormat, Object... messages) static ApiExceptionnew403Forbidden(Throwable cause) static ApiExceptionnew403Forbidden(Throwable cause, String messageFormat, Object... messages) static ApiExceptionstatic ApiExceptionnew404NotFound(String messageFormat, Object... messages) static ApiExceptionnew404NotFound(Throwable cause) static ApiExceptionnew404NotFound(Throwable cause, String messageFormat, Object... messages) static ApiExceptionstatic ApiExceptionnew429TooManyRequests(String messageFormat, Object... messages) static ApiExceptionnew429TooManyRequests(Throwable cause) static ApiExceptionnew429TooManyRequests(Throwable cause, String messageFormat, Object... messages) 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 voidDeprecated.this pattern was throwing off static code analysis.static voidthrow400BadRequest(String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidthrow400BadRequest(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow400BadRequest(Throwable cause, String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow401Unauthroized(String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidthrow401Unauthroized(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow401Unauthroized(Throwable cause, String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow403Forbidden(String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidthrow403Forbidden(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow403Forbidden(Throwable cause, String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow404NotFound(String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidthrow404NotFound(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow404NotFound(Throwable cause, String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow429TooManyRequests(String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidthrow429TooManyRequests(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow429TooManyRequests(Throwable cause, String messageFormat, Object... messages) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow500InternalServerError(String messageFormat, Object... args) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow500InternalServerError(Throwable cause, String messageFormat, Object... args) Deprecated.this pattern was throwing off static code analysis.static voidDeprecated.this pattern was throwing off static code analysis.static voidthrow501NotImplemented(String messageFormat, Object... args) Deprecated.this pattern was throwing off static code analysis.static voidthrow501NotImplemented(Throwable cause) Deprecated.this pattern was throwing off static code analysis.static voidthrow501NotImplemented(Throwable cause, String messageFormat, Object... args) Deprecated.this pattern was throwing off static code analysis.static voidThrows a 500 INTERNAL SERVER ERROR ApiException with the given messagestatic voidstatic voidRethrowscauseas a 500 INTERNAL SERVER ERROR ApiExceptionwithStatus(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
- Throws:
ApiException
-
ApiException
public ApiException(String httpStatus, Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
-
Method Details
-
getMessage
public static String getMessage(String httpStatus, Throwable cause, 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:
httpStatus- the HTTP stats codde of the errorcause- the cause of the errormessageFormat- the caller supplied error message with variable placeholdersargs- variables to insert intomessageFormat- Returns:
- a hopefully user friendly error message
- See Also:
-
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(String status, Throwable cause, String messageFormat, Object... args) throws ApiException - Throws:
ApiException
-
new400BadRequest
- Throws:
ApiException
-
new400BadRequest
- Throws:
ApiException
-
new400BadRequest
public static ApiException new400BadRequest(String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new400BadRequest
public static ApiException new400BadRequest(Throwable cause, String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new401Unauthroized
- Throws:
ApiException
-
new401Unauthroized
- Throws:
ApiException
-
new401Unauthroized
public static ApiException new401Unauthroized(String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new401Unauthroized
public static ApiException new401Unauthroized(Throwable cause, String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new403Forbidden
- Throws:
ApiException
-
new403Forbidden
- Throws:
ApiException
-
new403Forbidden
public static ApiException new403Forbidden(String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new403Forbidden
public static ApiException new403Forbidden(Throwable cause, String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new404NotFound
- Throws:
ApiException
-
new404NotFound
- Throws:
ApiException
-
new404NotFound
public static ApiException new404NotFound(String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new404NotFound
public static ApiException new404NotFound(Throwable cause, String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new429TooManyRequests
- Throws:
ApiException
-
new429TooManyRequests
- Throws:
ApiException
-
new429TooManyRequests
public static ApiException new429TooManyRequests(String messageFormat, Object... messages) throws ApiException - Throws:
ApiException
-
new429TooManyRequests
public static ApiException new429TooManyRequests(Throwable cause, String messageFormat, Object... messages) 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
-
getStatus
-
withStatus
-
hasStatus
public boolean hasStatus(int... statusCodes) -
throw400BadRequest
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw400BadRequest
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw400BadRequest
@Deprecated public static void throw400BadRequest(String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw400BadRequest
@Deprecated public static void throw400BadRequest(Throwable cause, String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw401Unauthroized
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw401Unauthroized
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw401Unauthroized
@Deprecated public static void throw401Unauthroized(String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw401Unauthroized
@Deprecated public static void throw401Unauthroized(Throwable cause, String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw403Forbidden
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw403Forbidden
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw403Forbidden
@Deprecated public static void throw403Forbidden(String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw403Forbidden
@Deprecated public static void throw403Forbidden(Throwable cause, String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw404NotFound
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw404NotFound
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw404NotFound
@Deprecated public static void throw404NotFound(String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw404NotFound
@Deprecated public static void throw404NotFound(Throwable cause, String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw429TooManyRequests
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw429TooManyRequests
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw429TooManyRequests
@Deprecated public static void throw429TooManyRequests(String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw429TooManyRequests
@Deprecated public static void throw429TooManyRequests(Throwable cause, String messageFormat, Object... messages) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw500InternalServerError
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw500InternalServerError
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw500InternalServerError
@Deprecated public static void throw500InternalServerError(String messageFormat, Object... args) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw500InternalServerError
@Deprecated public static void throw500InternalServerError(Throwable cause, String messageFormat, Object... args) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw501NotImplemented
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw501NotImplemented
Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw501NotImplemented
@Deprecated public static void throw501NotImplemented(String messageFormat, Object... args) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-
throw501NotImplemented
@Deprecated public static void throw501NotImplemented(Throwable cause, String messageFormat, Object... args) throws ApiException Deprecated.this pattern was throwing off static code analysis. It is recommended to replace the usage of this method with "throw ApiException.newXXX(...)- Throws:
ApiException
-