aspectguy (4) [Avatar] Offline
#1
Hi,
I am advicing all the methods in a library. basically I do around advice and have a generic implementation. How can I propagate exceptions of any type from my generic advice. Can I wrap it in some RuntimeException and expect aspect to unwrap it and propagate it up the stack.


e.g:-
class A
{
void a() throws IOException
{
....
}
}

class B{
void b() throws IllegalStatException
{
}
}

Next I will have a pointcut that will capture both these methods(all this works fine except for exception propagation):-
pointcut inject() execution(* *(..))
advice:-
Object around() : inject()
{
// do some work here.
// this could generate IOException or IllegalStateException
// but I cant propagate this up unless I have throws clause for the around //advice.How do I do it without explicitly listing all the exceptions using throws clause? Can I wrap it in some exception have the aspectj unwrap it and propagate it up?
}

Thanks,
Vipin
aspectguy (4) [Avatar] Offline
#2
Re: Aspectj throwing of exception
I have worked around this issue for from outside the aspect context.
But if there is a one shot solution besides softening each of those exceptions one by one using declare soft, let me know.