You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an exception is thrown in a dispatch loop event, beforeExecuteRoute for instance, beforeException never gets fired off.
This had been working in Phalcon 1.3.5, until I recently updated to Phalcon 2.0.10. Not sure if the desired functionality has changed, or if this is a bug. But I had found it useful when beforeException was fired off whenever an exception was thrown in a controller or other dispatch loop event.
Reproducible Test
<?phpusePhalcon\Mvc\View;
usePhalcon\DI\FactoryDefault;
usePhalcon\Mvc\Application;
usePhalcon\Mvc\Controller;
usePhalcon\Mvc\Dispatcher;
usePhalcon\Events\Event;
classIndexControllerextendsController
{
publicfunctionindexAction() {
echo'This is a test.';
}
}
classAuthPlugin
{
publicfunctionbeforeExecuteRoute(Event$event, Dispatcher$dispatcher, $exception)
{
thrownewException('Catch me in ExceptionPlugin, please!');
}
}
classExceptionPlugin
{
publicfunctionbeforeException(Event$event, Dispatcher$dispatcher, $exception)
{
echo'I should end up here first.';
}
}
$di = newFactoryDefault();
$di->set('dispatcher', function() use($di) {
$dispatcher = newDispatcher();
$eventsManager = $di->getShared('eventsManager');
$eventsManager->attach('dispatch', newAuthPlugin());
$eventsManager->attach('dispatch', newExceptionPlugin());
$dispatcher->setEventsManager($eventsManager);
return$dispatcher;
}, true);
$di->set('view', function () {
$view = newView();
return$view;
}, true);
$app = newApplication();
$app->setDi($di);
try {
echo$app->handle()->getContent();
} catch (Exception$e) {
echo'I should end up here second.';
}
Expected Result I should end up here first. I should end up here second.
Observed Result I should end up here second.
The text was updated successfully, but these errors were encountered:
rkeplin
changed the title
[2.0.10] beforeException not executing when exception is thrown in dispatch loop events
[2.0.10] dispatch:beforeException not executing when exception is thrown in dispatch process
Feb 29, 2016
When an exception is thrown in a dispatch loop event, beforeExecuteRoute for instance, beforeException never gets fired off.
This had been working in Phalcon 1.3.5, until I recently updated to Phalcon 2.0.10. Not sure if the desired functionality has changed, or if this is a bug. But I had found it useful when beforeException was fired off whenever an exception was thrown in a controller or other dispatch loop event.
Reproducible Test
Expected Result
I should end up here first. I should end up here second.
Observed Result
I should end up here second.
The text was updated successfully, but these errors were encountered: