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. |
@Nonnull protected abstract ClassT self()
this. Needed to facilitate a fluent interface in the implementing classes.@Nonnull protected ResponseWithErrorCode toResponseWithErrorCode(@Nonnull Throwable throwable)
Throwable into a ResponseWithErrorCode, using the mappings stored in the
ErrorResponseBuilder.throwable - The Throwable to handle.ResponseWithErrorCode for the given Throwable.@Nonnull public <ThrowableT extends Throwable> ClassT removeMapping(@Nonnull Class<ThrowableT> tClass)
Throwable class.ThrowableT - The type of the class to be removed.tClass - The class to remove the mapping for.@Nonnull public <ThrowableT extends Throwable> ClassT withMapper(@Nonnull 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.@Nonnull public <ThrowableT extends Throwable & WithErrorResponse> ClassT withMapper(@Nonnull ResponseMapper<ThrowableT> responseMapper, @Nonnull 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.@Nonnull public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsLevel(@Nonnull Class<ThrowableT> throwableClass, @Nonnull 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.@Nonnull public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsError(@Nonnull 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.@Nonnull public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsWarning(@Nonnull 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.@Nonnull public <ThrowableT extends Throwable & WithErrorResponse> ClassT logAsInfo(@Nonnull 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 © 2022 SAP SE. All rights reserved.