@ControllerAdvice public class SpringExceptionMapper extends AbstractExceptionMapper<SpringExceptionMapper>
ControllerAdvice
mechanic.
This handler catches all Throwable
s, logs them on the server side, and fills the response with the status
code and error description. To change/override this behavior either use the methods defined in the
AbstractExceptionMapper
, or write a custom mapper with the ControllerAdvice
annotation and a
Priority
higher then the default one.
Note that CloudLoggerFactory
is not used here to avoid recursion.
Constructor and Description |
---|
SpringExceptionMapper() |
Modifier and Type | Method and Description |
---|---|
String |
handleException(Throwable t,
javax.servlet.http.HttpServletResponse response)
Logs the
Throwable and fills the HttpServletResponse with the status code and description
provided by the ErrorResponseBuilder . |
protected SpringExceptionMapper |
self()
Getter for
this . |
getErrorResponseBuilder, logAsError, logAsInfo, logAsLevel, logAsWarning, removeMapping, toResponseWithErrorCode, withMapper, withMapper
@ExceptionHandler @ResponseBody public String handleException(Throwable t, javax.servlet.http.HttpServletResponse response)
Throwable
and fills the HttpServletResponse
with the status code and description
provided by the ErrorResponseBuilder
.t
- The Throwable
to handle.response
- The HttpServletResponse
to be filled with the status code and description.HttpServletResponse
.protected SpringExceptionMapper self()
AbstractExceptionMapper
this
. Needed to facilitate a fluent interface in the implementing classes.self
in class AbstractExceptionMapper<SpringExceptionMapper>
Copyright © 2018 SAP SE. All rights reserved.