@@ -99,7 +99,10 @@ public function onDispatch(MvcEvent $e)
9999 } catch (InvalidServiceException $ exception ) {
100100 $ return = $ this ->marshalControllerNotFoundEvent ($ application ::ERROR_CONTROLLER_INVALID , $ controllerName , $ e , $ application , $ exception );
101101 return $ this ->complete ($ return , $ e );
102- } catch (\Exception $ exception ) {
102+ } catch (\Throwable $ exception ) {
103+ $ return = $ this ->marshalBadControllerEvent ($ controllerName , $ e , $ application , $ exception );
104+ return $ this ->complete ($ return , $ e );
105+ } catch (\Exception $ exception ) { // @TODO clean up once PHP 7 requirement is enforced
103106 $ return = $ this ->marshalBadControllerEvent ($ controllerName , $ e , $ application , $ exception );
104107 return $ this ->complete ($ return , $ e );
105108 }
@@ -110,15 +113,22 @@ public function onDispatch(MvcEvent $e)
110113
111114 $ request = $ e ->getRequest ();
112115 $ response = $ application ->getResponse ();
116+ $ caughtException = null ;
113117
114118 try {
115119 $ return = $ controller ->dispatch ($ request , $ response );
116- } catch (\Exception $ ex ) {
120+ } catch (\Throwable $ ex ) {
121+ $ caughtException = $ ex ;
122+ } catch (\Exception $ ex ) { // @TODO clean up once PHP 7 requirement is enforced
123+ $ caughtException = $ ex ;
124+ }
125+
126+ if ($ caughtException !== null ) {
117127 $ e ->setName (MvcEvent::EVENT_DISPATCH_ERROR );
118128 $ e ->setError ($ application ::ERROR_EXCEPTION );
119129 $ e ->setController ($ controllerName );
120130 $ e ->setControllerClass (get_class ($ controller ));
121- $ e ->setParam ('exception ' , $ ex );
131+ $ e ->setParam ('exception ' , $ caughtException );
122132
123133 $ return = $ application ->getEventManager ()->triggerEvent ($ e )->last ();
124134 if (! $ return ) {
@@ -136,7 +146,7 @@ public function reportMonitorEvent(MvcEvent $e)
136146 {
137147 $ error = $ e ->getError ();
138148 $ exception = $ e ->getParam ('exception ' );
139- if ($ exception instanceof \Exception) {
149+ if ($ exception instanceof \Exception || $ exception instanceof \Throwable ) { // @TODO clean up once PHP 7 requirement is enforced
140150 zend_monitor_custom_event_ex ($ error , $ exception ->getMessage (), 'Zend Framework Exception ' , ['code ' => $ exception ->getCode (), 'trace ' => $ exception ->getTraceAsString ()]);
141151 }
142152 }
0 commit comments