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 String
ERROR_CODE_ALREADY_EXISTS
Default 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 protected
ServiceException()
Instantiates a new service exception.protected
ServiceException(int httpStatus, String errorCode)
Instantiates a new service exception.protected
ServiceException(int httpStatus, String errorCode, String reason)
Instantiates a new service exception.protected
ServiceException(int httpStatus, String errorCode, String reason, Throwable cause)
Instantiates a new service exception.protected
ServiceException(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 ServiceException
alreadyExists()
Already exists service exception.static ServiceException
alreadyExists(Object entityName)
Already exists service exception.static ServiceException
alreadyExists(String entityType, Object entityName)
Already exists service exception.static ServiceException
alreadyExistsWithErrorCode(Object entityName, String errorCode)
Already exists with error code service exception.static ServiceException
alreadyExistsWithErrorCode(String entityType, Object entityName, String errorCode)
Already exists with error code service exception.static ServiceException
badRequest()
Bad request service exception.static ServiceException
badRequest(String reason)
Bad request service exception.static ServiceException
badRequest(String reason, String errorCode)
Bad request service exception.static ServiceException
badRequest(String reason, String errorCode, Throwable cause)
Bad request service exception.static ServiceException
badRequest(String reason, Throwable cause)
Bad request service exception.static ServiceExceptionBuilder<? extends ServiceException>
builder()
Creates new exception builder.static ServiceException
forbidden()
Forbidden service exception.static ServiceException
forbidden(Object entityName)
Forbidden service exception.static ServiceException
forbidden(String entityType, Object entityName)
Forbidden service exception.static ServiceException
forbiddenWithErrorCode(Object entityName, String errorCode)
Forbidden with error code service exception.static ServiceException
forbiddenWithErrorCode(String errorCode)
Forbidden with error code service exception.static ServiceException
forbiddenWithErrorCode(String entityType, Object entityName, String errorCode)
Forbidden with error code service exception.static ServiceException
internalServerError()
Internal server error service exception.static ServiceException
internalServerError(String reason)
Internal server error service exception.static ServiceException
internalServerError(String reason, String errorCode)
Internal server error service exception.static ServiceException
internalServerError(String reason, String errorCode, Throwable cause)
Internal server error service exception.static ServiceException
internalServerError(String reason, Throwable cause)
Internal server error service exception.static ServiceException
notFound()
Not found service exception.static ServiceException
notFound(Object entityName)
Not found service exception.static ServiceException
notFound(String entityType, Object entityName)
Not found service exception.static ServiceException
notFoundWithErrorCode(Object entityName, String errorCode)
Not found with error code service exception.static ServiceException
notFoundWithErrorCode(String entityType, Object entityName, String errorCode)
Not found with error code service exception.int
status()
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:
status
in 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
-
-