public class LogOrRethrowExceptionHandler extends java.lang.Object implements ExceptionHandler
ExceptionHandler
based on an Classifier
.
The classifier determines whether to log the exception or rethrow it. The
keys in the classifier must be the same as the static enum in this class.Modifier and Type | Class and Description |
---|---|
static class |
LogOrRethrowExceptionHandler.Level
Logging levels for the handler.
|
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
LogOrRethrowExceptionHandler() |
Modifier and Type | Method and Description |
---|---|
void |
handleException(RepeatContext context,
java.lang.Throwable throwable)
Classify the throwables and decide whether to rethrow based on the
result.
|
void |
setExceptionClassifier(org.springframework.classify.Classifier<java.lang.Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
Setter for the
Classifier used by this handler. |
public void setExceptionClassifier(org.springframework.classify.Classifier<java.lang.Throwable,LogOrRethrowExceptionHandler.Level> exceptionClassifier)
Classifier
used by this handler. The default is to
map all throwable instances to LogOrRethrowExceptionHandler.Level.RETHROW
.exceptionClassifier
- the ExceptionClassifier to usepublic void handleException(RepeatContext context, java.lang.Throwable throwable) throws java.lang.Throwable
handleException
in interface ExceptionHandler
context
- the current RepeatContext
. Can be used to store
state (via attributes), for example to count the number of occurrences of
a particular exception type and implement a threshold policy.throwable
- an exception.java.lang.Throwable
- thrown if exceptionClassifier
is classified as LogOrRethrowExceptionHandler.Level.RETHROW
.ExceptionHandler.handleException(RepeatContext, Throwable)