If you look at the Zend Framework 2 MVC module you will see possibilities for this..
DispatchListener.php
try {
$return = $controller->dispatch($request, $response);
} catch (\Exception $ex) {
$e->setError($application::ERROR_EXCEPTION)
->setController($controllerName)
->setControllerClass(get_class($controller))
->setParam('exception', $ex);
// look here...
$results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e);
$return = $results->last();
if (! $return) {
$return = $e->getResult();
}
}
You can see they MvcEvent which is triggered when you have an exception thrown inside the controller, there's a few other processes attaching to this event.
You could attach a method to this event and do what ever you want.
As an example look at ExceptionStrategy.php
public function prepareExceptionViewModel(MvcEvent $e)
{
....
}