Interface ExceptionHandlerAware
- All Known Implementing Classes:
AmexChannel, ASCIIChannel, BASE24Channel, BASE24TCPChannel, BaseChannel, BCDChannel, CMFChannel, CSChannel, FSDChannel, GICCChannel, GZIPChannel, HEXChannel, LogChannel, NACChannel, NCCChannel, PADChannel, PostChannel, RawChannel, RBPChannel, TelnetXMLChannel, VAPChannel, X25Channel, XMLChannel
public interface ExceptionHandlerAware
Interface that modifies an implementing class to add an exception handling pipeline.
The main pipeline consists of multiple sub-pipelines:
- A pipeline for which handlers are called regardless of the type of exception handled. Stored under a null key.
- A pipeline per targeted exception type.
In the event that both of the pipelines are empty, the default behavior is to rethrow the initial exception.
There is no need to implement the methods unless you override the default behavior.
- Since:
- 2.1.2
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddHandler(ExceptionHandler handler) Add a handler to the default pipeline.default voidaddHandler(ExceptionHandler handler, Class<? extends Exception> clazz) Add a handler to an exception specific pipeline.Map<Class<? extends Exception>, List<ExceptionHandler>> default ExceptionExecute the pipeline by starting with the specific pipeline for the exception followed by the default pipeline.default voidremoveHandler(ExceptionHandler handler) Remove a handler from the default pipeline.default voidremoveHandler(ExceptionHandler handler, Class<? extends Exception> clazz) Remove a handler from an exception specific handler pipeline.default voidremoveHandlers(Class<? extends Exception> clazz) Remove all handler for a specific exception handling pipeline.
-
Method Details
-
getExceptionHandlers
Map<Class<? extends Exception>, List<ExceptionHandler>> getExceptionHandlers()- Returns:
- A map of exception classes to exception handlers. These handlers only execute if the exception matches.
-
addHandler
Add a handler to the default pipeline.- Parameters:
handler- ExceptionHandler to add.
-
addHandler
Add a handler to an exception specific pipeline.- Parameters:
handler- ExceptionHandler to add.clazz- Exception handler pipeline to add it to.
-
removeHandler
Remove a handler from the default pipeline.- Parameters:
handler- ExceptionHandler to remove.
-
removeHandler
Remove a handler from an exception specific handler pipeline. The list of exception handlers is removed once the last handler has been removed.- Parameters:
handler- ExceptionHandler to remove.clazz- Exception pipeline to remove it from.
-
removeHandlers
Remove all handler for a specific exception handling pipeline.- Parameters:
clazz- Exception pipeline to remove.
-
handle
Execute the pipeline by starting with the specific pipeline for the exception followed by the default pipeline.
In the event of both pipelines being empty, the original exception is rethrown.- Parameters:
e- Initial exception.- Returns:
- Same, modified or new exception.
- Throws:
Exception- In the event of a handler throwing an exception. Processing by further handlers would be cancelled.
-