ClassT
- The type of the implementing class.public abstract class AbstractExceptionMapper<ClassT extends AbstractExceptionMapper<ClassT>> extends Object
Provides different methods to modify the underlying Exception
mapping.
Constructor and Description |
---|
AbstractExceptionMapper() |
Modifier and Type | Method and Description |
---|---|
ErrorResponseBuilder |
getErrorResponseBuilder() |
<ThrowableT extends Throwable & WithErrorResponse> |
logAsError(Class<ThrowableT> throwableClass)
Only sets the error log level for any
Throwable of the given type. |
<ThrowableT extends Throwable & WithErrorResponse> |
logAsInfo(Class<ThrowableT> throwableClass)
Only sets the info log level for any
Throwable of the given type. |
<ThrowableT extends Throwable & WithErrorResponse> |
logAsLevel(Class<ThrowableT> throwableClass,
LogLevel logLevel)
Only sets a specific server-side log level for any
Throwable of the given type. |
<ThrowableT extends Throwable & WithErrorResponse> |
logAsWarning(Class<ThrowableT> throwableClass)
Only sets the warning log level for any
Throwable of the given type. |
<ThrowableT extends Throwable> |
removeMapping(Class<ThrowableT> tClass)
Removes the mapping for the given
Throwable class. |
protected abstract ClassT |
self()
Getter for
this . |
protected ResponseWithErrorCode |
toResponseWithErrorCode(Throwable throwable)
Wraps the given
Throwable into a ResponseWithErrorCode , using the mappings stored in the
ErrorResponseBuilder . |
<ThrowableT extends Throwable> |
withMapper(ResponseMapper<ThrowableT> mapper)
Adds the given
ResponseMapper for the Throwable specified insider the mapper. |
<ThrowableT extends Throwable & WithErrorResponse> |
withMapper(ResponseMapper<ThrowableT> responseMapper,
LogLevel logLevel)
Adds the given
ResponseMapper for the Throwable specified insider the mapper. |
protected abstract ClassT self()
this
. Needed to facilitate a fluent interface in the implementing classes.protected ResponseWithErrorCode toResponseWithErrorCode(Throwable throwable)
Throwable
into a ResponseWithErrorCode
, using the mappings stored in the
ErrorResponseBuilder
.throwable
- The Throwable
to handle.ResponseWithErrorCode
for the given Throwable
.public <ThrowableT extends Throwable> ClassT removeMapping(Class<ThrowableT> tClass)
Throwable
class.ThrowableT
- The type of the class to be removed.tClass
- The class to remove the mapping for.public <ThrowableT extends Throwable> ClassT withMapper(ResponseMapper<ThrowableT> mapper)
ResponseMapper
for the Throwable
specified insider the mapper.ThrowableT
- The type of the Throwable
the mapper handles.mapper
- The mapper to add.public <ThrowableT extends Throwable & WithErrorResponse> ClassT withMapper(ResponseMapper<ThrowableT> responseMapper, LogLevel logLevel)
ResponseMapper
for the Throwable
specified insider the mapper. Also adds a custom
LogLevel
used to server-side log any Throwable
of the specified type.ThrowableT
- The type of the exception to be handled.responseMapper
- The mapper to add.logLevel
- The LogLevel
to use for server-side logging of the Throwable
.public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsLevel(Class<ThrowableT> throwableClass, LogLevel logLevel)
Throwable
of the given type.ThrowableT
- The type of the Throwable
to log.throwableClass
- The class of Throwable
which should be logged with a specific LogLevel
.logLevel
- The LogLevel
to use.public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsError(Class<ThrowableT> throwableClass)
Throwable
of the given type.ThrowableT
- The type of the Throwable
to log.throwableClass
- The class of Throwable
which should be logged as error.public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsWarning(Class<ThrowableT> throwableClass)
Throwable
of the given type.ThrowableT
- The type of the Throwable
to log.throwableClass
- The class of Throwable
which should be logged as warning.public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsInfo(Class<ThrowableT> throwableClass)
Throwable
of the given type.ThrowableT
- The type of the Throwable
to log.throwableClass
- The class of Throwable
which should be logged as info.@Nonnull public ErrorResponseBuilder getErrorResponseBuilder()
Copyright © 2018 SAP SE. All rights reserved.