Hello, i have problem with classic \Exception.
My code:
$di->set(
'dispatcher',
function () {
$dispatcher = new Dispatcher();
$eventsManager = new EventsManager();
$eventsManager->attach(
'dispatch:beforeException',
new DispatcherLisener()
);
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}
);
class DispatcherLisener extends \Phalcon\Mvc\User\Component
{
public function beforeException(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher, \Exception $exception): bool
{
if ($exception instanceof \Phalcon\Mvc\Dispatcher\Exception) {
$this->response->redirect('misc/error/show404');
} else {
$this->response->redirect('misc/error/show500');
}
return false;
}
}
class AccountController extends \Phalcon\Mvc\Controller
{
public function listAction()
{
throw new \Exception();
}
}
404 work fine, but i cant catch 500 exception. Any sugestions?