/** * Before exception is happening. * * @param Event $event Event object. * @param Dispatcher $dispatcher Dispatcher object. * @param PhalconException $exception Exception object. * * @throws \Phalcon\Exception * @return bool */ public function beforeException($event, $dispatcher, $exception) { // Handle 404 exceptions. if ($exception instanceof DispatchException) { $dispatcher->forward(['module' => EngineApplication::SYSTEM_DEFAULT_MODULE, 'namespace' => ucfirst(EngineApplication::SYSTEM_DEFAULT_MODULE) . '\\Controller', 'controller' => 'Error', 'action' => 'show404']); return false; } if (APPLICATION_STAGE == APPLICATION_STAGE_DEVELOPMENT) { throw $exception; } else { EngineException::logException($exception); } // Handle other exceptions. $dispatcher->forward(['module' => EngineApplication::SYSTEM_DEFAULT_MODULE, 'namespace' => ucfirst(EngineApplication::SYSTEM_DEFAULT_MODULE) . '\\Controller', 'controller' => 'Error', 'action' => 'show500']); return $event->isStopped(); }