Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] exception handling

Hi Jan,

I believe this kind of exception handling can be handled effectively by using 
call pointcut descriptors. In fact, in an early version of aTrack, I did use 
call instead of execution, except that I was concerned about the large number 
of try catch blocks. So you can certainly use AspectJ to convert exceptions 
from method calls, for example based on the exception's type and the layer of 
the system. 

That being said, it's less clear to me whether the JDC example you cited has 
a crosscutting rule that it's enforcing. It throws a specific exception in 
two places in one method (with different context in each) and catch it in 
exactly one other place. As an aside, I don't think this style of exception 
handling scales very well to large systems, and they didn't address logging 
problems either.

Ron

On Wed, 07 Jan 2004 17:19:45 +0100, Jan Van Besien wrote
> Considering exception handling as a croscutting concern (you could discuss
> that), I'm thinking about different options on how to tackle this 
> with AOP
> (using AspectJ).
> 
> The idea that Ramnivas Laddad proposes in [1] works perfectly well 
> in his example, because exception handling is done on a "per method 
> base". I mean that -simply said- every method (in the original java 
> example) starts with 'try' and ends with 'catch'. As far is I know,
>  this is also the approach used in ATrack [2], where exceptions are 
> converted to uncheck layer specific exceptions, and then handled on 
> the boundary to the next layer.
> 
> But what about "refactoring" exception handling techniques that are 
> not implemented on a "per method base". For example [3] (a JDC tech 
> tip) gives a demonstration on how to implement good exception 
> handling for a java program that reads a file. The basic techniques are
> 
> - deal with exceptions close to their source
> - and as specifically as possible
> 
> The resulting code is full of statements like 'try', 'catch', 'else 
> throw new..', 'System.err.println..', etc. In fact, for everything 
> that can go wrong, there is a "throw new SomeSpecificException 
> (message)" statement.
> 
> In my opinion, the same specific exception-handling result as in the 
> Java-implementation, can not be achieved with the AOP-techniques 
> from [1] and [2].
> 
> questions:
> 
> - should we come up with another technique for this kind of 
> exception handling?
> 
> - is AOP usefull for this kind of exception handling?
> 
> - is it realistic to think that a programmer could be oblivious from 
> exception handling when using AOP techniques?
> 
> - ...
> 
> Jan
> 
> [1] 
> http://www.theserverside.com/resources/article.jsp?
l=AspectOrientedRefactoringPart2
> 
> [2] https://atrack.dev.java.net/
> 
> [3] http://java.sun.com/developer/JDCTechTips/2003/tt1104.html#1
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users



Ron Bodkin
Chief Technology Officer
New Aspects
m: (415) 509-2895


Back to the top