In my application i have 100 classes and each class contains 4 methods each.
I am using try catch for exception handling. I write try catch in each method , then there will be 400 try catch statement in my application. Is it affect the performance of my application? Is it possible to handle the whole exception using one try catch statement in the whole application?
In my application i have 100 classes and each class contains 4 methods each.
Share
Do you need to handle exceptions within each method? Typically that’s not the way things work – in my experience, most exceptions can’t really be handled in a better way than telling the user something went wrong and aborting the higher-level action, which could involve a stack of several methods.
So normally you’ll have a very few try/catch blocks at the “top” level, and the methods doing most of the work will just let the exceptions bubble up.