Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to detect exception in the control flow of an aspect

> "R. Dale Asberry" wrote:
> 
> How can I detect when an exception has occurred in the control flow of an
> aspect if the exception gets handled?

Some code would help here to disambiguate what you're after.

Things you probably already know:

- after throwing advice runs when join point processing completes abruptly,
  throwing an exception.

- the PCD cflow(..) picks out join points in the control flow of a join point

- the PCD handler(FooError) picks out FooError exception handlers

- If the exception is handled within a join point -- e.g.,

   try {...}
   catch (FooError e) {...}

  -- then it does not cause the join point to complete abruptly

- the call(..) PCD can pick out the construction of exceptions:

    call(Throwable+.new(..)) ...

  but that won't pick out exceptions thrown from library code
  and might be hard to associate with enclosing join points.

So you can say

    before() : call(Throwable+.new(..)) && cflow(testcase())...

or

    before() : handler(FooError) && cflow(testcase())...

or
    after throwing (FooError) : cflow(testcase()) ...

or ???

Wes


Back to the top