Skip to main content

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

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


Back to the top