I have a Java exception handling design question .
I have a Backing layer(java bean class) in my web app.
I would like to catch the exceptions(RunTimeE) thrown by all the methods in a class in single place. My backing bean class extends the AbstractBackingBean class.
Is there any way ,can i catch the exceptions from all the methods and log it in one place.
Yes. For a web application you can do that in a
Filter:If a filter is not an option for some reason, take a look at AOP. For example spring has good AOP support. It’s similar to the filter approach, but you specify exactly which classes and methods you want to attach the handler to.