[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Method return value in case of exception

You need to keep track of the logged exception and make sure that you don't log it again. For an example, see source code of AspectJ in Action (specifically exception logging example in chapter 10); you can download code from http://manning.com/laddad2.

-Ramnivas

On Wed, Sep 23, 2009 at 2:59 AM, Nikolas Nehmer <nnehmer@xxxxxxxxxxxxxxxxxxxx> wrote:
Hi,

currently I'm writing a tool logging method calls and corresponding return values (among other things). Using "after() throwing" capturing the result of a method in case of an exception is easily possible. Unfortunately (to capture the exception return value) AspectJ seems to inject try catch blocks around every method call on the propagation path.
Example:
A is calling B is calling C is calling D, an Exception is raised in D an caught in A

Using JDI's ExceptionEvent (running the app in debugging mode) one would expect one single ExceptionEvent (caused by the Exception raised in D)  with ExceptionEvent.catchLocation() returning A...

Using:
after() throwing(Throwable o): methodCall() {
  //doSomething
}
results in several ExceptionEvents caused by every propagation step on the exception propagation path. Obviously each method call is implicitly wrapped by a try catch block rethrowing the exception raised in D. Unfortunately this implicitly changes the exception propagation behaviour of the application.

Any ideas on how to circumvent this implicit catch and rethrow mechanism while keeping the possibility to capture method calls and results in case of an exception?

Cheers
Nikolas
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users