[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] How to use aspectj to all the exceptions?
|
Your last advice already has the exception object to use in the advice body:
after() throwing(Exception e) : execution(* *.*(..)) {
System.out.println("aspect after throwing exception. The exception is" +
e);
}
-Ramnivas
===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com
M: (408)203-4621
China Creatxr wrote:
> aspectj-users,
>
> I want to use aspectj to logger the exceptions. so I implemnt a aspect
> class named LoggerAspect below.
> I can catch the exceptions now, but I don't know how to get the
> exception objects.
> How to?
>
> import org.aspectj.lang.Signature;
> public aspect LoggerAspect {
> pointcut exceptionLoggerMethods() : call (public
> java.lang.Exception+.new(..)) && !within(LoggerAspect);
> before() : exceptionLoggerMethods() {
> System.out.println("aspect before exception"); Signature sig =
> thisJoinPointStaticPart.getSignature();
> System.out.println(sig.getName());
> }
> after() : exceptionLoggerMethods(){
> System.out.println("aspect after exception"); }
>
> after() throwing(Exception e) : execution(* *.*(..)) {
> System.out.println("aspect after throwing exception");
>
> }
> }
>
> creatxr,creatxr@xxxxxxxxxxx
> 2006-4-16
>
> _________________________________________________________________
> 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>