To go deeper and know how to use Exceptions in a real project, you can read the following article:
11 Mistakes Java Developers Make when Using Exceptions
If you have any questions about this Java Challenge, don’t hesitate to leave a question!
Keep breaking your limits!
How to handle exception and send notifications in Apache camel?
Hi Zishan, I would need more context in your question. The principles to handle Exceptions are pretty much the same with any tool. Try to apply them in the same way with Apache Camel.
I think your explanation is wrong in one point: The FileNotFoundException will be caught in the outer try-catch-finally-block (the one that adds “exc” and “fin”). However, you state that the code execution “continues” and that the NPE is thrown and caught in that particular catch block. The line that throws the NPE will not be executed at all.
The solution is still the same.
Thanks for the feedback, Michael. Now, the answer is fixed without the previous ambiguity.