Skip to content

Instantly share code, notes, and snippets.

@alexshelkov
Last active December 13, 2015 18:18
Show Gist options
  • Save alexshelkov/4954354 to your computer and use it in GitHub Desktop.
Save alexshelkov/4954354 to your computer and use it in GitHub Desktop.
<?php
// somewhere in the module code
public function onBootstrap(EventInterface $event)
{
/** @var \Zend\Mvc\MvcEvent $event */
$application = $event->getApplication();
$application->getEventManager()->attach('dispatch', function(MvcEvent $event) use ($application) {
try {
// some code that may throw exception
throw new \Exception('test');
} catch(\Exception $e) {
$event->
setError($application::ERROR_EXCEPTION)->
setParam('exception', $e);
$application->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event);
}
}, 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment