If I understand you correctly, you want the listener to connect to the EVENT_DISPATCH_ERROR event to handle the exception you raise.
To do this, instead of simply throw exception, you should trigger the send error event yourself with an instance of your exception as one of its parameters, for example ...
class Module { public function onBootstrap(EventInterface $event) { $application = $event->getTarget(); $eventManager = $application->getEventManager(); $eventManager->attach(MvcEvent::EVENT_DISPATCH, function(MvcEvent $event) use ($eventManager) {
after starting your error listener should take over and handle your exception
Crisp source share