Categories
Articles

Exception Handling – AOP way

Exceptions, part of life. 🙂 But if we can handle them in well defined manner, life becomes very easy. I couldn’t find any suitable framework in Java taking care of exceptions.

Recently I came across Spring – RCP (Rich Client Project – not sure if project is dead couldn’t see any major release in recent past and the manual still in TODO mode), and found that it provides nice way to handle exceptions in Spring way. While it provides way to execute handlers based on type of exception being thrown, it doesn’t offer feature of executing handlers based on the type of object (Class) throwing an error.
So I thought of implementing my own exception handler using Spring and AOP which can help me to define exception handling for class as well as for type of exception and leverage all features of Spring in handlers.
Watch this space for further information.

Finally done with creation of Exception handling framework and would be publishing artifacts related to it in next few days.
Following diagram depicts class structure for framework.
Exception Framework Class Diagram
The diagram shows various built-in handlers and configuration option that come built-in with framework.
Lets have a look at the sequence diagram which shows flow of operations when an exception occurs.
Exception Framework Sequence
The ExceptionProcessor displayed in above diagrams is invoked by custom interceptor available with framework. In case of non-spring application, it can be executed by an implementation of UncaughtExceptionHandler (available with core Java).
I will soon release more details about configuration and framework files.

By Carbon Rider

Hi this is Yogesh, welcome to my world. Being passionate about learning new technologies and building frameworks, I end up spending most of my time in front of computer. But over last few months, I realised apart from being good coder and designer (Yes I am) I have something hidden in me. And thats called ART.

Leave a Reply