Skip to main content

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


Thanks it worked! I was making it too complicated by trying syntax such as throwing(*) etc.

aspectj-users-bounces@xxxxxxxxxxx wrote on 14/11/2007 14:50:57:

> Use Throwable instead. It's the "mother" of all exceptions :-)
>
> On 14/11/2007, Ashley Williams <ashley.williams@xxxxxx> wrote:
> >
> > Hi,
> >
> > I'm trying to write a tracing aspect and would like to report any exceptions
> > thrown as part of the logging format, but I can't find a way to express this
> > in a generic fashion my after advice. Here is an example:
> >
> > // methods annotated with @Tracing will be picked out by the tracing aspect
> > public class MyClass {
> >
> >         @Tracing
> >         public void foo()         {
> >                 // would like to log this exception
> >                 throw new RuntimeException(e);
> >         }
> >
> > }
> >
> > public aspect Tracing {
> >         // all methods marked with @Tracing annotation
> >         pointcut traceableMethod(Tracing tracing) : execution(@Tracing *
> > *(..)) && @annotation(tracing);
> >
> >         // log exception information for all @Tracing annotated methods
> >         // don't want to hardcode throwing(RuntimeException) though
> >         after(Tracing tracing) throwing : traceableMethod(tracing) {
> >                 // do log4j logging here
> >         }
> > }
> >
> > I want to capture all types of exceptions that may be thrown, and not have
> > to hardcode RuntimeException as in the example above. Is this possible in
> > AspectJ?
> >
> > Help appreciated
> > - Ashley Williams
> >
> >  ---
> >
> >  This e-mail may contain confidential and/or privileged information. If you
> > are not the intended recipient (or have received this e-mail in error)
> > please notify the sender immediately and delete this e-mail. Any
> > unauthorized copying, disclosure or distribution of the material in this
> > e-mail is strictly forbidden.
> >
> >  Please refer to
> > http://www.db.com/en/content/eu_disclosures.htm for
> > additional EU corporate and regulatory disclosures.
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>
>
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users

---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.


Back to the top