Esempio n. 1
0
 public function beforeException(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher, \Phalcon\Exception $exception)
 {
     switch ($exception->getCode()) {
         case $dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
         case $dispatcher::EXCEPTION_ACTION_NOT_FOUND:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'notFound'));
             return false;
         default:
             $dispatcher->forward(array('controller' => 'error', 'action' => 'uncaughtException'));
             return false;
     }
 }
 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param MvcDispatcher $dispatcher
  * @param Exception $exception
  * @return boolean
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)
 {
     error_log($exception->getMessage() . PHP_EOL . $exception->getTraceAsString());
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 $dispatcher->forward(array('controller' => 'errors', 'action' => 'show404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'errors', 'action' => 'show500'));
     return false;
 }