I'm using latest phalcon version (2.0.6). The problem is as described - I throw an error in beforeDispatch and expect it to be served by the logic placed in beforeException
service.php
$eventsManager->attach('dispatch:beforeDispatchLoop', new Thrower());
$eventsManager->attach('dispatch:beforeException', new Catcher());
Thrower.php
class Thrower extends Plugin
{
public function beforeDispatchLoop(Event $event, Dispatcher $dispatcher)
{
throw new \Exception('Exception');
}
}
Catcher.php
class Catcher extends Plugin
{
public function beforeException(Event $event, Dispatcher $dispatcher)
{
// it doesnt get executed
$dispatcher->forward(array('controller' => 'error', 'action' => 'error'));
}
}
does phalcon support catching exceptions thrown inside beforeDispatchLoop/beforeDispatch? Or did I miss anything? exception thrown inside controllers/services get caught.