Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] intercept exception and replace with return value (with AfterThrowing advice)

You have to use "around" advice to change the control flow. Something like this in your advice block:

try {
proceed (args);
} catch (ExceptionIWantToCatch e) {


On Mar 26, 2008, at 9:14 AM, manuel aldana wrote:

inside my code i would like to intercept an exception an replace it with a
return value? so my aspect is kind of a mediator which translates an
exception to a proper return value.
is this possible with aspectj?

something like:
@AfterThrowing(pointcut="call(@InterceptHandling *
public void replaceExceptionWithReturnValue(JoinPoint jp,Throwable
exception){          //handle exception
//create value and pass it as return value to method-callers

thanks for help.

manuel aldana

aspectj-users mailing list

Dean Wampler, Ph.D.
dean at
See also:     AOP for Ruby         Design by Contract for Java5

Back to the top