Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] aspect for Catch Exception

But that won't tell you where the exception was raised - just where it
was caught.

Eric

On 07/10/2007, Dehua Zhang <dehua.zhang@xxxxxxxxxxxxxx> wrote:
>
> It seems little bit late, hope you already got the solution.
>
> this thisJoinPoint.getSignature() can be casted into different types in package org.aspectj.lang.reflect to get additional information.
> http://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/reflect/package-summary.html
>
> For your situation, ((MethodSignature)thisJoinPoint.getSignature()).getName() should work.
>
> Regards,
> --
> Dehua (Andy) Zhang
> Sable Research Group, McGill University
> Montréal, Québec, Canada
> http://www.cs.mcgill.ca/~dzhang25
>
>
>
>
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Filipe Costa
> Sent: Thu 8/30/2007 06:37
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] aspect for Catch Exception
>
> Hi
>
> I'm starting with AspectJ and I have a lot of packages and in which them
> java classes. I want to do an aspect that capture every exceptions and do
> something like that:
>
> logger.logp(Level.SEVERE, <class name>.class.getName(), "method name",
> e.getMessage());
>
> Because every exceptions has a same kind of catch, like that:
>
> (.)
> catch(<something>Exception e)
>             {
>                 logger.logp(Level.SEVERE, <class name>, <method name>,
> e.getMessage());
>             }
>
> I have this aspect:
>
> import java.util.logging.Logger;
>
> public aspect Catch_Exc {
>
>     Logger log = Logger.global;
>
>     public pointcut detect():
>         call(public * *.*(..));
>
>     after() throwing (Exception e): detect()
>     {
>
>         logger.logp(Level.SEVERE,
>
> thisJoinPoint.getSignature().getDeclaringType().getName(),
> //for class name
>                         <method name>,  //for method name???
>                         e.getMessage());
>      }
> }
>
> Can I know the method name that throws the exception, someone have an idea?
>
> thank you
>
>
> --
> fg_costa
> [Filipe Costa]
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


Back to the top