The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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.