public class ExceptionSafeErrorHandler extends java.lang.Object implements ErrorHandler
Wrapping error handler that ensures that no exceptions are thrown. This
wrapper can be used by code that calls an error handler to ensure that the
handleError(Class, Throwable, String)
method does not throw an
exception, if there is an implementation bug in the error handler.
This error handler simply delegates to the error handler specified at construction time and catches any exception the delegate error-handler might throw.
Constructor and Description |
---|
ExceptionSafeErrorHandler(ErrorHandler delegate)
Creates an error handler that never thrown an exception from the
specified error handler.
|
Modifier and Type | Method and Description |
---|---|
void |
handleError(java.lang.Class<?> context,
java.lang.Throwable e,
java.lang.String description)
Handles an error.
|
public ExceptionSafeErrorHandler(ErrorHandler delegate)
null
, this error handler simply ignores all calls to
handleError(Class, Throwable, String)
.delegate
- error handler to which calls of
handleError(Class, Throwable, String)
should be
delegated or null
if these calls should simply be
ignored.public void handleError(java.lang.Class<?> context, java.lang.Throwable e, java.lang.String description)
ErrorHandler
Handles an error. This method is called if the library code detects an
exception that it cannot handle internally or detects another abnormal
situation. At least one of e
and description
is
guaranteed not to be null
.
This method should not throw an exception, but if it does, this exception will simply be ignored.
handleError
in interface ErrorHandler
context
- the class that called the error handler. This information can
be used to determine in which component an exception occurred
if the same exception handler is registered for various
components.e
- exception that was encountered by library code and could not
be handled internally or null
if no exception is
available.description
- some additional information about the context in which the
error occurred or null
if no such information is
available.Copyright © 2014–2024 aquenos GmbH. All rights reserved.