chaitanya chaitanya - 17 days ago 6
Java Question

framework for handling exception in java

Is there any framework that can handle java exception such that there is no need for writing

try catch
blocks in java .
Here exception's were both checked and unchecked exception .
Either by using annotation or any other kind of patterns. Is there a way to this thing globally like a framework such that it can be used for any other projects.

Answer

Instead of catching the exception, you can always throw it.

The point of exceptions is that they do not need to be handled directly where they are thrown but in any of the calling methods where it might make more sense. This can very well be in the main method of your main class.

If you find yourself writing code where each function call is wrapped in its own try block, you are probably doing exception handling wrong.

I cannot imagine a general exception handling framework, that does more than Java exceptions already do, to be useful.