Class LogOrRethrowExceptionHandler
java.lang.Object
org.springframework.batch.repeat.exception.LogOrRethrowExceptionHandler
- All Implemented Interfaces:
ExceptionHandler
Implementation of
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.- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumLogging levels for the handler. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleException(RepeatContext context, Throwable throwable) Classify the throwables and decide whether to rethrow based on the result.voidsetExceptionClassifier(org.springframework.classify.Classifier<Throwable, LogOrRethrowExceptionHandler.Level> exceptionClassifier) Setter for theClassifierused by this handler.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
LogOrRethrowExceptionHandler
public LogOrRethrowExceptionHandler()
-
-
Method Details
-
setExceptionClassifier
public void setExceptionClassifier(org.springframework.classify.Classifier<Throwable, LogOrRethrowExceptionHandler.Level> exceptionClassifier) Setter for theClassifierused by this handler. The default is to map all throwable instances toLogOrRethrowExceptionHandler.Level.RETHROW.- Parameters:
exceptionClassifier- the ExceptionClassifier to use
-
handleException
Classify the throwables and decide whether to rethrow based on the result. The context is not used.- Specified by:
handleExceptionin interfaceExceptionHandler- Parameters:
context- the currentRepeatContext. 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.- Throws:
Throwable- thrown ifexceptionClassifieris classified asLogOrRethrowExceptionHandler.Level.RETHROW.- See Also:
-