Package org.bremersee.exception
Class ServiceException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.bremersee.exception.ServiceException
-
- All Implemented Interfaces:
Serializable,ErrorCodeAware,HttpStatusAware
- Direct Known Subclasses:
LdaptiveException,MinioException
public class ServiceException extends RuntimeException implements ErrorCodeAware, HttpStatusAware
General service exception with http status code and error code.- Author:
- Christian Bremer
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringERROR_CODE_ALREADY_EXISTSDefault error code for an 'already exists exception'.-
Fields inherited from interface org.bremersee.exception.ErrorCodeAware
NO_ERROR_CODE_VALUE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServiceException()Instantiates a new service exception.protectedServiceException(int httpStatus, String errorCode)Instantiates a new service exception.protectedServiceException(int httpStatus, String errorCode, String reason)Instantiates a new service exception.protectedServiceException(int httpStatus, String errorCode, String reason, Throwable cause)Instantiates a new service exception.protectedServiceException(int httpStatus, String errorCode, Throwable cause)Instantiates a new service exception.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServiceExceptionalreadyExists()Already exists service exception.static ServiceExceptionalreadyExists(Object entityName)Already exists service exception.static ServiceExceptionalreadyExists(String entityType, Object entityName)Already exists service exception.static ServiceExceptionalreadyExistsWithErrorCode(Object entityName, String errorCode)Already exists with error code service exception.static ServiceExceptionalreadyExistsWithErrorCode(String entityType, Object entityName, String errorCode)Already exists with error code service exception.static ServiceExceptionbadRequest()Bad request service exception.static ServiceExceptionbadRequest(String reason)Bad request service exception.static ServiceExceptionbadRequest(String reason, String errorCode)Bad request service exception.static ServiceExceptionbadRequest(String reason, String errorCode, Throwable cause)Bad request service exception.static ServiceExceptionbadRequest(String reason, Throwable cause)Bad request service exception.static ServiceExceptionBuilder<? extends ServiceException>builder()Creates new exception builder.static ServiceExceptionforbidden()Forbidden service exception.static ServiceExceptionforbidden(Object entityName)Forbidden service exception.static ServiceExceptionforbidden(String entityType, Object entityName)Forbidden service exception.static ServiceExceptionforbiddenWithErrorCode(Object entityName, String errorCode)Forbidden with error code service exception.static ServiceExceptionforbiddenWithErrorCode(String errorCode)Forbidden with error code service exception.static ServiceExceptionforbiddenWithErrorCode(String entityType, Object entityName, String errorCode)Forbidden with error code service exception.static ServiceExceptioninternalServerError()Internal server error service exception.static ServiceExceptioninternalServerError(String reason)Internal server error service exception.static ServiceExceptioninternalServerError(String reason, String errorCode)Internal server error service exception.static ServiceExceptioninternalServerError(String reason, String errorCode, Throwable cause)Internal server error service exception.static ServiceExceptioninternalServerError(String reason, Throwable cause)Internal server error service exception.static ServiceExceptionnotFound()Not found service exception.static ServiceExceptionnotFound(Object entityName)Not found service exception.static ServiceExceptionnotFound(String entityType, Object entityName)Not found service exception.static ServiceExceptionnotFoundWithErrorCode(Object entityName, String errorCode)Not found with error code service exception.static ServiceExceptionnotFoundWithErrorCode(String entityType, Object entityName, String errorCode)Not found with error code service exception.intstatus()Get the http status.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.bremersee.exception.ErrorCodeAware
getErrorCode
-
-
-
-
Field Detail
-
ERROR_CODE_ALREADY_EXISTS
public static final String ERROR_CODE_ALREADY_EXISTS
Default error code for an 'already exists exception'.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServiceException
protected ServiceException()
Instantiates a new service exception.
-
ServiceException
protected ServiceException(int httpStatus, String errorCode)Instantiates a new service exception.- Parameters:
httpStatus- the http statuserrorCode- the error code
-
ServiceException
protected ServiceException(int httpStatus, String errorCode, String reason)Instantiates a new service exception.- Parameters:
httpStatus- the http statuserrorCode- the error codereason- the reason
-
ServiceException
protected ServiceException(int httpStatus, String errorCode, Throwable cause)Instantiates a new service exception.- Parameters:
httpStatus- the http statuserrorCode- the error codecause- the cause
-
-
Method Detail
-
status
public int status()
Get the http status.- Specified by:
statusin interfaceHttpStatusAware- Returns:
- the http status
-
internalServerError
public static ServiceException internalServerError()
Internal server error service exception.- Returns:
- the service exception
-
internalServerError
public static ServiceException internalServerError(String reason)
Internal server error service exception.- Parameters:
reason- the reason- Returns:
- the service exception
-
internalServerError
public static ServiceException internalServerError(String reason, Throwable cause)
Internal server error service exception.- Parameters:
reason- the reasoncause- the cause- Returns:
- the service exception
-
internalServerError
public static ServiceException internalServerError(String reason, String errorCode)
Internal server error service exception.- Parameters:
reason- the reasonerrorCode- the error code- Returns:
- the service exception
-
internalServerError
public static ServiceException internalServerError(String reason, String errorCode, Throwable cause)
Internal server error service exception.- Parameters:
reason- the reasonerrorCode- the error codecause- the cause- Returns:
- the service exception
-
badRequest
public static ServiceException badRequest()
Bad request service exception.- Returns:
- the service exception
-
badRequest
public static ServiceException badRequest(String reason)
Bad request service exception.- Parameters:
reason- the reason- Returns:
- the service exception
-
badRequest
public static ServiceException badRequest(String reason, Throwable cause)
Bad request service exception.- Parameters:
reason- the reasoncause- the cause- Returns:
- the service exception
-
badRequest
public static ServiceException badRequest(String reason, String errorCode)
Bad request service exception.- Parameters:
reason- the reasonerrorCode- the error code- Returns:
- the service exception
-
badRequest
public static ServiceException badRequest(String reason, String errorCode, Throwable cause)
Bad request service exception.- Parameters:
reason- the reasonerrorCode- the error codecause- the cause- Returns:
- the service exception
-
notFound
public static ServiceException notFound()
Not found service exception.- Returns:
- the service exception
-
notFound
public static ServiceException notFound(Object entityName)
Not found service exception.- Parameters:
entityName- the entity name- Returns:
- the service exception
-
notFound
public static ServiceException notFound(String entityType, Object entityName)
Not found service exception.- Parameters:
entityType- the entity typeentityName- the entity name- Returns:
- the service exception
-
notFoundWithErrorCode
public static ServiceException notFoundWithErrorCode(Object entityName, String errorCode)
Not found with error code service exception.- Parameters:
entityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
notFoundWithErrorCode
public static ServiceException notFoundWithErrorCode(String entityType, Object entityName, String errorCode)
Not found with error code service exception.- Parameters:
entityType- the entity typeentityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
alreadyExists
public static ServiceException alreadyExists()
Already exists service exception.- Returns:
- the service exception
-
alreadyExists
public static ServiceException alreadyExists(Object entityName)
Already exists service exception.- Parameters:
entityName- the entity name- Returns:
- the service exception
-
alreadyExists
public static ServiceException alreadyExists(String entityType, Object entityName)
Already exists service exception.- Parameters:
entityType- the entity typeentityName- the entity name- Returns:
- the service exception
-
alreadyExistsWithErrorCode
public static ServiceException alreadyExistsWithErrorCode(Object entityName, String errorCode)
Already exists with error code service exception.- Parameters:
entityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
alreadyExistsWithErrorCode
public static ServiceException alreadyExistsWithErrorCode(String entityType, Object entityName, String errorCode)
Already exists with error code service exception.- Parameters:
entityType- the entity typeentityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
forbidden
public static ServiceException forbidden()
Forbidden service exception.- Returns:
- the service exception
-
forbidden
public static ServiceException forbidden(Object entityName)
Forbidden service exception.- Parameters:
entityName- the entity name- Returns:
- the service exception
-
forbidden
public static ServiceException forbidden(String entityType, Object entityName)
Forbidden service exception.- Parameters:
entityType- the entity typeentityName- the entity name- Returns:
- the service exception
-
forbiddenWithErrorCode
public static ServiceException forbiddenWithErrorCode(String errorCode)
Forbidden with error code service exception.- Parameters:
errorCode- the error code- Returns:
- the service exception
-
forbiddenWithErrorCode
public static ServiceException forbiddenWithErrorCode(Object entityName, String errorCode)
Forbidden with error code service exception.- Parameters:
entityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
forbiddenWithErrorCode
public static ServiceException forbiddenWithErrorCode(String entityType, Object entityName, String errorCode)
Forbidden with error code service exception.- Parameters:
entityType- the entity typeentityName- the entity nameerrorCode- the error code- Returns:
- the service exception
-
builder
public static ServiceExceptionBuilder<? extends ServiceException> builder()
Creates new exception builder.- Returns:
- the builder
-
-