Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] after throwing question ...

How so? You can mask exceptions with around advice by catching them and you
can have a finally block after that. For example:

aspect ErrorHandling {
   pointcut handled() : ...;

   Object around() : handled() {
       try {
           return proceed();
       } catch (ThisException e) {
           disableOptionalService();
           // ok - handled
       } finally {
           releaseResources();
       }
   }
...
}

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Fernando Castor
Filho
Sent: Friday, September 22, 2006 4:31 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] after throwing question ...

This is the main reason why it is not possible to implement exception
masking with around advice. It is also not possible to mimic the
semantics of "finally" blocks.


Kind regards,
Fernando

On 9/22/06, Ron Bodkin <rbodkin@xxxxxxxxxxxxxx> wrote:
> Hi Fabio,
>
> You could rethrow another exception in after throwing advice but to exit
the
> join point without throwing you would need to catch it in an around
advice.
>
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Fabio Fagundes
> Silveira
> Sent: Friday, September 22, 2006 10:26 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] after throwing question ...
>
> Hello,
>
>    Is there any way to "stop" an exception propagation raised in a
> method?  For example:
>
>   after(Object o, double d) throwing:
>          execution(* Foo.m1(..)) &&
>          target(o)
>          && args(d){
>
>                 //do something
>
>                 //stop the exception propagation
>
>                         }
>
>                 }
>
>
>   In such example, after m1 returns with an exception raised, I would
> like to do something and stop or "catch" such an exception ... I know
> that with around it is possible ... but is it with after throwing?
>
> Regards,
> Fabio
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top