[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] exception handling
|
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