Introduction to Aspect-Oriented Programming
Subject:   Exceptions
Date:   2004-02-17 14:14:13
From:   grahamoregan
Response to: Exceptions

Thats a difficult question to answer, not because AOP makes it difficult to handle, but you need to be clear on when you add AOP to your applications, i.e. are you designing your application to use AOP from the outset? You also need to be clear on where and when you use checked and unchecked exceptions.

If you are adding AOP to an existing application then exception handling could become a difficult issue to overcome. Your existing code may already be dealing with checked (usually critical) and unchecked (exceptions you can recover from) exceptions. You could take the line that the code within your model, along with business classes, deals with unchecked exceptions with checked exceptions being handled by control classes, including AOP code.

Once you're clear on the use of AOP and exception handling then you can decide what you should do when exceptions occur. Remember that Aspectwerkz allows to you take control of an application at specified points and control flow from that point. Ultimately you will need to be clear on your objectives before introducing AOP, if you do decide to use AOP then you will have to make sure that exceptions are definitely handled in the correct manner, there is no room for poor exception handling in the controlling classes of your application.

I HTH, but it is a difficult question to answer without a specific case in mind.