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_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 and Description |
|---|
ApiException() |
ApiException(java.lang.String httpStatus) |
ApiException(java.lang.String messageFormat,
java.lang.Object... args) |
ApiException(java.lang.String httpStatus,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
ApiException(java.lang.Throwable cause) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getMessage(java.lang.String httpStatus,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
Supports error message construction including variable replacement supporting
logging framework "{}" placesholders OR java.util.Formatter style placeholders.
|
java.lang.String |
getStatus() |
boolean |
hasStatus(int... statusCodes) |
static void |
throw400BadRequest() |
static void |
throw400BadRequest(java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw400BadRequest(java.lang.Throwable cause) |
static void |
throw400BadRequest(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw401Unauthroized() |
static void |
throw401Unauthroized(java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw401Unauthroized(java.lang.Throwable cause) |
static void |
throw401Unauthroized(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw403Forbidden() |
static void |
throw403Forbidden(java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw403Forbidden(java.lang.Throwable cause) |
static void |
throw403Forbidden(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw404NotFound() |
static void |
throw404NotFound(java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw404NotFound(java.lang.Throwable cause) |
static void |
throw404NotFound(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw429TooManyRequests() |
static void |
throw429TooManyRequests(java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw429TooManyRequests(java.lang.Throwable cause) |
static void |
throw429TooManyRequests(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages) |
static void |
throw500InternalServerError() |
static void |
throw500InternalServerError(java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throw500InternalServerError(java.lang.Throwable cause) |
static void |
throw500InternalServerError(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throw501NotImplemented() |
static void |
throw501NotImplemented(java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throw501NotImplemented(java.lang.Throwable cause) |
static void |
throw501NotImplemented(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throwEx(java.lang.String messageFormat,
java.lang.Object... messages)
Throws a 500 INTERNAL SERVER ERROR ApiException with the given message
|
static void |
throwEx(java.lang.String status,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args) |
static void |
throwEx(java.lang.Throwable cause)
Rethrows
cause as a 500 INTERNAL SERVER ERROR ApiException |
ApiException |
withStatus(java.lang.String status) |
public ApiException()
throws ApiException
ApiExceptionpublic ApiException(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic ApiException(java.lang.String httpStatus)
throws ApiException
ApiExceptionpublic ApiException(java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic ApiException(java.lang.String httpStatus,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static java.lang.String getMessage(java.lang.String httpStatus,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
Any "{}" substrings in messageFormat are replaced with "{}"
before messageFormat and args are passed to a
java.util.Formatter.
All arguments are optional but if everything is null you will get an empty string.
httpStatus - cause - messageFormat - args - public java.lang.String getStatus()
public ApiException withStatus(java.lang.String status)
public boolean hasStatus(int... statusCodes)
public static void throw400BadRequest()
throws ApiException
ApiExceptionpublic static void throw400BadRequest(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw400BadRequest(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw400BadRequest(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw401Unauthroized()
throws ApiException
ApiExceptionpublic static void throw401Unauthroized(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw401Unauthroized(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw401Unauthroized(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw403Forbidden()
throws ApiException
ApiExceptionpublic static void throw403Forbidden(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw403Forbidden(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw403Forbidden(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw404NotFound()
throws ApiException
ApiExceptionpublic static void throw404NotFound(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw404NotFound(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw404NotFound(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw429TooManyRequests()
throws ApiException
ApiExceptionpublic static void throw429TooManyRequests(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw429TooManyRequests(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw429TooManyRequests(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
ApiExceptionpublic static void throw500InternalServerError()
throws ApiException
ApiExceptionpublic static void throw500InternalServerError(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw500InternalServerError(java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static void throw500InternalServerError(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static void throw501NotImplemented()
throws ApiException
ApiExceptionpublic static void throw501NotImplemented(java.lang.Throwable cause)
throws ApiException
ApiExceptionpublic static void throw501NotImplemented(java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static void throw501NotImplemented(java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionpublic static void throwEx(java.lang.Throwable cause)
throws ApiException
cause as a 500 INTERNAL SERVER ERROR ApiExceptioncause - ApiExceptionpublic static void throwEx(java.lang.String messageFormat,
java.lang.Object... messages)
throws ApiException
messageFormat - messages - ApiExceptionpublic static void throwEx(java.lang.String status,
java.lang.Throwable cause,
java.lang.String messageFormat,
java.lang.Object... args)
throws ApiException
ApiExceptionCopyright © 2024 Rocket Partners, LLC. All rights reserved.