Package org.bremersee.exception
Class RestApiExceptionMapperForWeb
java.lang.Object
org.bremersee.exception.RestApiExceptionMapperForWeb
- All Implemented Interfaces:
- RestApiExceptionMapper
The implementation of a rest api exception mapper for spring web.
- Author:
- Christian Bremer
- 
Constructor SummaryConstructorsConstructorDescriptionRestApiExceptionMapperForWeb(RestApiExceptionMapperProperties properties, String applicationName) Instantiates a new rest api exception mapper.
- 
Method SummaryModifier and TypeMethodDescriptionorg.bremersee.exception.model.RestApiExceptionBuild the exception model from the exception, the requested path and a handler.protected org.springframework.http.HttpStatusCodedetectHttpStatus(Throwable exception, Object handler) Detect http status http status.findHandlerClass(Object handler) Find the handler class.findHandlerMethod(Object handler) Find the handler method.protected Optional<org.springframework.http.HttpStatusCode>fromStatus(Integer status) From status optional.protected StringGets error.protected org.bremersee.exception.model.RestApiExceptionreconfigureRestApiException(org.bremersee.exception.model.RestApiException source, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Reconfigure rest api exception rest api exception.protected org.bremersee.exception.model.RestApiExceptionsetApplication(org.bremersee.exception.model.RestApiException restApiException, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets application.protected org.bremersee.exception.model.RestApiExceptionsetCause(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets cause.protected org.bremersee.exception.model.RestApiExceptionsetClassName(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets class name.protected org.bremersee.exception.model.RestApiExceptionsetErrorCode(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets error code.protected org.bremersee.exception.model.RestApiExceptionsetHandler(org.bremersee.exception.model.RestApiException restApiException, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets handler.protected org.bremersee.exception.model.RestApiExceptionsetMessage(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets message.protected org.bremersee.exception.model.RestApiExceptionsetPath(org.bremersee.exception.model.RestApiException restApiException, String path, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets path.protected org.bremersee.exception.model.RestApiExceptionsetStackTrace(org.bremersee.exception.model.RestApiException restApiException, StackTraceElement[] stackTrace, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets stack trace.
- 
Constructor Details- 
RestApiExceptionMapperForWebpublic RestApiExceptionMapperForWeb(RestApiExceptionMapperProperties properties, String applicationName) Instantiates a new rest api exception mapper.- Parameters:
- properties- the properties
- applicationName- the application name
 
 
- 
- 
Method Details- 
detectHttpStatusprotected org.springframework.http.HttpStatusCode detectHttpStatus(Throwable exception, Object handler) Detect http status http status.- Parameters:
- exception- the exception
- handler- the handler
- Returns:
- the http status
 
- 
fromStatusFrom status optional.- Parameters:
- status- the status
- Returns:
- the optional
 
- 
getError@Nullable protected String getError(Throwable throwable, org.springframework.http.HttpStatusCode httpStatusCode) Gets error.- Parameters:
- throwable- the throwable
- httpStatusCode- the http status code
- Returns:
- the error
 
- 
buildpublic org.bremersee.exception.model.RestApiException build(Throwable exception, String requestPath, Object handler) Description copied from interface:RestApiExceptionMapperBuild the exception model from the exception, the requested path and a handler. Typically, the handler is of typeHandlerMethod.- Specified by:
- buildin interface- RestApiExceptionMapper
- Parameters:
- exception- the exception (required)
- requestPath- the requested path (optional)
- handler- the handler (optional)
- Returns:
- the rest api exception
 
- 
findHandlerClassFind the handler class.- Parameters:
- handler- the handler
- Returns:
- the class
 
- 
findHandlerMethodFind the handler method.- Parameters:
- handler- the handler
- Returns:
- the method
 
- 
setErrorCodeprotected org.bremersee.exception.model.RestApiException setErrorCode(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets error code.- Parameters:
- restApiException- the rest api exception
- exception- the exception
- handler- the handler
- config- the config
- Returns:
- the error code
 
- 
setMessageprotected org.bremersee.exception.model.RestApiException setMessage(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets message.- Parameters:
- restApiException- the rest api exception
- exception- the exception
- handler- the handler
- config- the config
- Returns:
- the message
 
- 
setClassNameprotected org.bremersee.exception.model.RestApiException setClassName(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets class name.- Parameters:
- restApiException- the rest api exception
- exception- the exception
- config- the config
- Returns:
- the class name
 
- 
setApplicationprotected org.bremersee.exception.model.RestApiException setApplication(org.bremersee.exception.model.RestApiException restApiException, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets application.- Parameters:
- restApiException- the rest api exception
- config- the config
- Returns:
- the application
 
- 
setPathprotected org.bremersee.exception.model.RestApiException setPath(org.bremersee.exception.model.RestApiException restApiException, String path, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets path.- Parameters:
- restApiException- the rest api exception
- path- the path
- config- the config
- Returns:
- the path
 
- 
setHandlerprotected org.bremersee.exception.model.RestApiException setHandler(org.bremersee.exception.model.RestApiException restApiException, Object handler, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets handler.- Parameters:
- restApiException- the rest api exception
- handler- the handler
- config- the config
- Returns:
- the handler
 
- 
setStackTraceprotected org.bremersee.exception.model.RestApiException setStackTrace(org.bremersee.exception.model.RestApiException restApiException, StackTraceElement[] stackTrace, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets stack trace.- Parameters:
- restApiException- the rest api exception
- stackTrace- the stack trace
- config- the config
- Returns:
- the stack trace
 
- 
setCauseprotected org.bremersee.exception.model.RestApiException setCause(org.bremersee.exception.model.RestApiException restApiException, Throwable exception, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Sets cause.- Parameters:
- restApiException- the rest api exception
- exception- the exception
- config- the config
- Returns:
- the cause
 
- 
reconfigureRestApiExceptionprotected org.bremersee.exception.model.RestApiException reconfigureRestApiException(org.bremersee.exception.model.RestApiException source, RestApiExceptionMapperProperties.ExceptionMappingConfig config) Reconfigure rest api exception rest api exception.- Parameters:
- source- the source
- config- the config
- Returns:
- the rest api exception
 
 
-