[
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)
|
hi,
i thought the same, but i am already using another around-advice for the
respective method and around-advices for same join-points cannot be
chained together (i guess).
i need a field being initialised in the proceed() for my exception
handling, but as i see from your code i should be able to access it in
the catch block. i should be able to access it through JoinPoint type.
thanks, your snippet showed me the way.
so, i will try to do the complete exception handling inside the same one
around-advice:
...
try {
return proceed (args);
} catch (ExceptionIWantToCatch e) {
do_recovery(argsFromJoinPointTarget);
...
return translatedExceptionToNormalReturnValue;
}
...
Dean Wampler schrieb:
You have to use "around" advice to change the control flow. Something
like this in your advice block:
try {
proceed (args);
} catch (ExceptionIWantToCatch e) {
do_recovery();
}
Dean
On Mar 26, 2008, at 9:14 AM, manuel aldana wrote:
hi,
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 *
aMethodCall(..))",throwing="exception")
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
aldana@xxxxxx <mailto:aldana@xxxxxx>
homepage: www.aldana-online.de
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Dean Wampler, Ph.D.
dean at objectmentor.com
http://www.objectmentor.com
See also:
http://www.aspectprogramming.com AOP advocacy site
http://aquarium.rubyforge.org AOP for Ruby
http://www.contract4j.org Design by Contract for Java5
------------------------------------------------------------------------
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
--
manuel aldana
aldana@xxxxxx
homepage: www.aldana-online.de