Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Pointcust for Catching Exceptions

Ron:

Thank you very much!  That solved the problem.  I was already
experimenting with the handler thanks to Ramnivas answer, but I could
not get it to work.  Your example helped a lot.

Regards,

Andreas


-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of DiFrango, Ron
Sent: Monday, October 18, 2004 1:35 PM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Pointcust for Catching Exceptions


Here is a general handler point cut that I use that picks out all catch
blocks:

public aspect ExceptionHandler
{
	point cut classList() : within(com..*);
	
	before(Throwable e) : 
		classList() 
		&& handler(*)
		&& args(e)
	{
		log(thisJoinPointStaticPart, e);	
	}
	
	private void log(JoinPoint.StaticPart jp, Throwable e)
	{
		System.out.println(jp.getSignature().getName()); 
		e.printStackTrace(System.out);
	
System.out.println(jp.getSignature().getDeclaringType());
	}
}

I would update the classList() pointcut to pick out only those classes
that you need.

-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Ramnivas Laddad
Sent: Monday, October 18, 2004 3:56 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Pointcust for Catching Exceptions


You need the handler() pointcut. See the AspectJ Programming Guide for 
more details.

-Ramnivas

===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com


Andreas Guther wrote:

> 
>Hi:
>
>I am stuck with the following problem and wonder if someone could point

>me to a solution:
>
>I am working on writing pointcuts for logging exceptions.  What works 
>fine is hitting methods which throw specific exceptions. We have a lot 
>of methods that handle Exceptions from lower level layers and wrap them

>into higher level layer Exceptions. Before those higher level 
>exceptions are thrown I would like to log the original exception, which

>takes place of course in the catch part.
> 
>Right now I have no idea how to define a pointcut that grabs the catch 
>part.  I looked around and so far I could not find examples.
>
>Any ideas how to solve that or where I could find examples?
>
>Thanks in advance for any hint.
>
>Regards,
>
>
>Andreas
> 
>--------------------------------------------------------
> 
>This electronic mail message contains information belonging to
>PaymentOne, which may be confidential and/or legal privileged. The
information is intended only for the use of the individual or entity
named above. If you are not the intended recipient, you are hereby
notified that any disclosure, printing, copying, distribution, or the
taking of any action in reliance on the contents of this electronically
mailed information is strictly prohibited. If you receive this message
in error, please immediately notify us by electronic mail and delete
this message.
>--------------------------------------------------------
> 
> 
>  
>_______________________________________________
>aspectj-users mailing list
>aspectj-users@xxxxxxxxxxx
>http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>  
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top