Getting a return value or exception from AspectJ?

Dallas picture Dallas · Apr 14, 2011 · Viewed 26.2k times · Source

I am able to get the signature and arguments from advised method calls, but I cannot figure out how to get the return values or exceptions. I'm kind of assuming that it can be done in some way using around and proceed.

Answer

Constantiner picture Constantiner · Apr 14, 2011

You can use after() returning and after() throwing advices as in beginning of the following document. If you're using @AspectJ syntax please refer to @AfterReturning and @AfterThrowing annotations (you can find samples here).