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
FieldsModifier and TypeFieldDescriptionstatic final StringDefault error code for an 'already exists exception'.Fields inherited from interface org.bremersee.exception.ErrorCodeAware
NO_ERROR_CODE_VALUE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiates 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
Modifier and TypeMethodDescriptionstatic ServiceExceptionAlready 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 ServiceExceptionBad 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 service exception.static ServiceExceptionForbidden service exception.static ServiceExceptionForbidden 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 ServiceExceptionInternal 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 ServiceExceptionNot found service exception.static ServiceExceptionNot 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
statusin 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
-