public class ApiException extends java.lang.RuntimeException implements Status
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
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 and Description |
|---|
ApiException() |
ApiException(java.lang.String messageFormat,
java.lang.Object... args) |
ApiException(java.lang.Throwable cause) |
ApiException(java.lang.Throwable cause,
java.lang.String httpStatus,
java.lang.String messageFormat,
java.lang.Object... args) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getMessage(java.lang.Throwable cause,
java.lang.String httpStatus,
java.lang.String messageFormat,
java.lang.Object... args)
Constructs a useful error message.
|
java.lang.String |
getStatus() |
int |
getStatusCode() |
boolean |
hasStatus(int... statusCodes) |
static ApiException |
new400BadRequest() |
static ApiException |
new400BadRequest(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new400BadRequest(java.lang.Throwable cause) |
static ApiException |
new400BadRequest(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new401Unauthroized() |
static ApiException |
new401Unauthroized(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new401Unauthroized(java.lang.Throwable cause) |
static ApiException |
new401Unauthroized(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new403Forbidden() |
static ApiException |
new403Forbidden(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new403Forbidden(java.lang.Throwable cause) |
static ApiException |
new403Forbidden(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new404NotFound() |
static ApiException |
new404NotFound(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new404NotFound(java.lang.Throwable cause) |
static ApiException |
new404NotFound(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new429TooManyRequests() |
static ApiException |
new429TooManyRequests(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new429TooManyRequests(java.lang.Throwable cause) |
static ApiException |
new429TooManyRequests(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new500InternalServerError() |
static ApiException |
new500InternalServerError(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new500InternalServerError(java.lang.Throwable cause) |
static ApiException |
new500InternalServerError(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new501NotImplemented() |
static ApiException |
new501NotImplemented(java.lang.String messageFormat,
java.lang.Object... args) |
static ApiException |
new501NotImplemented(java.lang.Throwable cause) |
static ApiException |
new501NotImplemented(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throwEx(java.lang.String messageFormat,
java.lang.Object... args)
Throws a "500 Internal Server Error" ApiException with the given message
|
static void |
throwEx(java.lang.Throwable cause)
Rethrows
cause as a "500 Internal Server Error" ApiException |
static void |
throwEx(java.lang.Throwable cause,
java.lang.String status,
java.lang.String messageFormat,
java.lang.Object... args) |
ApiException |
withStatus(java.lang.String status) |
public ApiException()
throws ApiException
ApiExceptionpublic ApiException(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic ApiException(java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic ApiException(java.lang.Throwable cause,
java.lang.String httpStatus,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic java.lang.String getStatus()
public ApiException withStatus(java.lang.String status)
public boolean hasStatus(int... statusCodes)
public int getStatusCode()
public static java.lang.String getMessage(java.lang.Throwable cause,
java.lang.String httpStatus,
java.lang.String messageFormat,
java.lang.Object... args)
All arguments are optional but if everything is null you will get an empty string.
cause - the cause of the errorhttpStatus - the HTTP stats codde of the errormessageFormat - the caller supplied error message with variable placeholdersargs - variables to insert into messageFormatUtils.format(String, Object...)public static void throwEx(java.lang.Throwable cause)
throws ApiException
cause as a "500 Internal Server Error" ApiExceptioncause - the cause of the errorApiException - alwayspublic static void throwEx(java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
messageFormat - the error message potentially with variablesargs - values substituted into messageFormatApiException - alwayspublic static void throwEx(java.lang.Throwable cause,
java.lang.String status,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static ApiException new400BadRequest() throws ApiException
ApiExceptionpublic static ApiException new400BadRequest(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new400BadRequest(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new400BadRequest(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new401Unauthroized() throws ApiException
ApiExceptionpublic static ApiException new401Unauthroized(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new401Unauthroized(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new401Unauthroized(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new403Forbidden() throws ApiException
ApiExceptionpublic static ApiException new403Forbidden(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new403Forbidden(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new403Forbidden(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new404NotFound() throws ApiException
ApiExceptionpublic static ApiException new404NotFound(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new404NotFound(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new404NotFound(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new429TooManyRequests() throws ApiException
ApiExceptionpublic static ApiException new429TooManyRequests(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new429TooManyRequests(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new429TooManyRequests(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new500InternalServerError() throws ApiException
ApiExceptionpublic static ApiException new500InternalServerError(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new500InternalServerError(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new500InternalServerError(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new501NotImplemented() throws ApiException
ApiExceptionpublic static ApiException new501NotImplemented(java.lang.Throwable cause) throws ApiException
ApiExceptionpublic static ApiException new501NotImplemented(java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionpublic static ApiException new501NotImplemented(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... args) throws ApiException
ApiExceptionCopyright © 2023 Rocket Partners, LLC. All rights reserved.