Here is an example, how to solve your issue with Go! AOP framework and Around
advice:
/**
* This advice intercepts an execution of some methods
*
* Logic is pretty simple: we wrap an original method with our advice
* and catch all exceptions in one place.
*
* @param MethodInvocation $invocation Invocation
*
* @Around("execution(public SomeClassName->*(*)")
*/
public function aroundPublicMethods(MethodInvocation $invocation)
{
try {
$result = $invocation->proceed(); // invoke original method
} catch (\Exception $e) {
$result = $e; // exception will be returned as a result to method call
}
return $result;
}
That's it.