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
General service exception with http status code and error code.
- Author:
- Christian Bremer
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default error code for an 'already exists exception'.Fields inherited from interface org.bremersee.exception.ErrorCodeAware
NO_ERROR_CODE_VALUE
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
Modifier and TypeMethodDescriptionstatic ServiceException
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
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 service exception.static ServiceException
Forbidden service exception.static ServiceException
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
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
Not found service exception.static ServiceException
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 Details
-
ERROR_CODE_ALREADY_EXISTS
Default error code for an 'already exists exception'.- See Also:
-
-
Constructor Details
-
ServiceException
protected ServiceException()Instantiates a new service exception. -
ServiceException
Instantiates a new service exception.- Parameters:
httpStatus
- the http statuserrorCode
- the error code
-
ServiceException
Instantiates a new service exception.- Parameters:
httpStatus
- the http statuserrorCode
- the error codereason
- the reason
-
ServiceException
Instantiates a new service exception.- Parameters:
httpStatus
- the http statuserrorCode
- the error codecause
- the cause
-
ServiceException
Instantiates a new service exception.- Parameters:
httpStatus
- the http statuserrorCode
- the error codereason
- the reasoncause
- the cause
-
-
Method Details
-
status
public int status()Get the http status.- Specified by:
status
in interfaceHttpStatusAware
- Returns:
- the http status
-
internalServerError
Internal server error service exception.- Returns:
- the service exception
-
internalServerError
Internal server error service exception.- Parameters:
reason
- the reason- Returns:
- the service exception
-
internalServerError
Internal server error service exception.- Parameters:
reason
- the reasoncause
- the cause- Returns:
- the service exception
-
internalServerError
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
Bad request service exception.- Returns:
- the service exception
-
badRequest
Bad request service exception.- Parameters:
reason
- the reason- Returns:
- the service exception
-
badRequest
Bad request service exception.- Parameters:
reason
- the reasoncause
- the cause- Returns:
- the service exception
-
badRequest
Bad request service exception.- Parameters:
reason
- the reasonerrorCode
- the error code- Returns:
- the service exception
-
badRequest
Bad request service exception.- Parameters:
reason
- the reasonerrorCode
- the error codecause
- the cause- Returns:
- the service exception
-
notFound
Not found service exception.- Returns:
- the service exception
-
notFound
Not found service exception.- Parameters:
entityName
- the entity name- Returns:
- the service exception
-
notFound
Not found service exception.- Parameters:
entityType
- the entity typeentityName
- the entity name- Returns:
- the service exception
-
notFoundWithErrorCode
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
Already exists service exception.- Returns:
- the service exception
-
alreadyExists
Already exists service exception.- Parameters:
entityName
- the entity name- Returns:
- the service exception
-
alreadyExists
Already exists service exception.- Parameters:
entityType
- the entity typeentityName
- the entity name- Returns:
- the service exception
-
alreadyExistsWithErrorCode
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
Forbidden service exception.- Returns:
- the service exception
-
forbidden
Forbidden service exception.- Parameters:
entityName
- the entity name- Returns:
- the service exception
-
forbidden
Forbidden service exception.- Parameters:
entityType
- the entity typeentityName
- the entity name- Returns:
- the service exception
-
forbiddenWithErrorCode
Forbidden with error code service exception.- Parameters:
errorCode
- the error code- Returns:
- the service exception
-
forbiddenWithErrorCode
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
Creates new exception builder.- Returns:
- the builder
-