This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Throwable vs. Exception #146
Closed
Description
I use zend-mvc 2.7.8. If i have a bad argument in my own factory the framework throws the following error :
Fatal error: Uncaught TypeError: Argument 4 passed to Zend\Mvc\DispatchListener::marshalBadControllerEvent() must be an instance of Exception, instance of TypeError given...
To fix this i've to change the the argument type in the DispatchListener class (method marshalBadControllerEvent) from
protected function marshalBadControllerEvent(
$controllerName,
MvcEvent $event,
Application $application,
\Exception $exception
) {
$event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
$event->setError($application::ERROR_EXCEPTION);
$event->setController($controllerName);
$event->setParam('exception', $exception);
$events = $application->getEventManager();
$results = $events->triggerEvent($event);
$return = $results->last();
if (! $return) {
return $event->getResult();
}
return $return;
}
to
protected function marshalBadControllerEvent(
$controllerName,
MvcEvent $event,
Application $application,
Throwable $exception
) {
$event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
$event->setError($application::ERROR_EXCEPTION);
$event->setController($controllerName);
$event->setParam('exception', $exception);
$events = $application->getEventManager();
$results = $events->triggerEvent($event);
$return = $results->last();
if (! $return) {
return $event->getResult();
}
return $return;
}