/** * "AfterThrowing" advice which tries to alter the thrown exception * * @param \AppserverIo\Psr\MetaobjectProtocol\Aop\MethodInvocationInterface $methodInvocation Initially invoked method * * @return null * * @AfterThrowing */ public function exceptionAlteringAfterThrowingAdvice(MethodInvocationInterface $methodInvocation) { // this goes without saying but our implementation should not allow to alter the exception in any way $methodInvocation->injectThrownException(new \Exception('Haha!')); $exception = $methodInvocation->getThrownException(); $exception = new \Exception('Haha!'); }