Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to catch java exception with aspectj

The exception object is only available through the throwing clause of the pointcut definition, as you have done with your first piece of advice:

 after() throwing(Throwable t): execution(* m()) {
    System.out.println(">"+t);
  }

At what joinpoint is that not working for you?

cheers,
Andy


On 8 January 2014 01:32, Krishna Jasty <krishna.jasty@xxxxxxx> wrote:
Hi,
I tried the following way to capture any exception object coming from java project.
But which is not getting invoked from aspectj,

pointcut customException():call(* *.*(..)  throws Exception);
    after() throwing(Exception ex): customException(){
            System.out.println("joinpoint is "+thisJoinPoint);
            System.out.println("exception is "+ ex);
    }


This one is getting invoked, but how to get the exception object with it.
        after(): execution(* **Throwable(..)){
        System.out.println("jointpoint is "+thisJoinPoint);
       
        log.error("Exception tracked in BaNCSDiagnostics> :"+ thisJoinPoint);
    }

Thanks,
Krishna

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you


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



Back to the top