So in my actions some functions may throw an exception, so I wanted to handle those in a single place. I thought a beforeException event was exactly what I was looking for. However I could not get it working.
Basically that's what I was doing
$eventsManager = new Phalcon\Events\Manager();
$eventsManager->attach("dispatch", function($event, $dispatcher, $exception) {
die(var_dump("Got there"));
});
$this->getDI()->get("dispatcher")->setEventsManager($eventsManager);
and then in action for example
public function indexAction() {
throw new \Exception("test");
}
However it didn't work. Exceptions thrown in actions were not caught. So, maybe they have to be specific exceptions?