Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] advice/exception

From exception handling perspective, think of advice as augmenting
functionality by overriding the adviced methods (or more accurately,
join points). This means, just like overridden methods, you cannot 
throw any checked exceptions that are not already declared to be 
thrown by the captured join points.

Please see more information on this in chapter 3 of my book
AspectJ in Action (the chapter is freely downloadable from
http://www.manning.com/laddad).

A solution is to throw a runtime (unchecked) exception from advice
when you detect a bad parameter. There is also exception 
introduction pattern discussed in AspectJ in Action. Howwever 
it may be an overkill for your problem.

-Ramnivas

===
Ramnivas Laddad, 
Author, AspectJ in Action 
http://www.manning.com/laddad
http://www.amazon.com/exec/obidos/ASIN/1930110936

Check out my aspect-oriented refactoring articles:
http://tinyurl.com/yqm96
http://tinyurl.com/288nn

--- franzr <reitinger.franz@xxxxxxxxx> wrote:
> Hi listeners,
> 
> I try to write an aspect which is responsible for checking parameters
> of 
> several methodes. The param-check is done within an advice (before);
> if the 
> check detects an invalid parameter an exception should be thrown to
> inform 
> the caller of this bad parameter.
> 
> However, it is not possible to compile this aspect because the
> compiler 
> finishes its work with an "Unhandled exception type ...".
> 
> Example:
> 
> before (KontoAsp  konto) :  execution(  public  *
> KontoAsp.ueberweisen( ..)) 
> && args(..,  konto)  {
> 	.......
> 		if (konto == null)
> 			throw new except.ProcessException(" ....");
> 			
> 	.......
> 	}
> 
> 
> What I'm doing wrong?
> Why does the compiler complains about an unhandled exception without
> knowing 
> the caller. It's the duty of the caller to manage exceptions.
> 
> ThanX
> franzR
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top