In our code we have a number of processors that implement the same interface.
By using spring and some arguments in our code, we lookup the correct concrete implementation of the IMsgProcessorInbound class to call.
When an exception occurs in any of these concrete implementations, i would like to catch the expception in the below try catch block.
Unforunately, this try catch block is never entered when an exception is thrown in the concrete implementation.
Is there any way I can catch the exceptions in the catch block listed below instead of littering all my concrete implementations with exception handling code?
Or is there some error handling functionality that spring can provide me?
IMsgProcessorInbound msgProcessor = msgProcessorSelectorInbound.lookupProcessorInbound(args);
try {
msgProcessor.processMsg(fixProcessorArgs);
} catch (Exception e) {
log.error("Exception is: " + e);
}
All help with this issue is greatly appreciated.
Thank you
Damien
Check this;
msgProcessor.processMsg() may not be throwing a type of Exception. The Throwable class is the superclass of all errors and exceptions. So the above should catch both checked and unchecked exceptions.
If you can’t still get into the catch block – then the msgProcessor.processMsg() may be swallowing exceptions.