Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. class ErrorController extends Zend_Controller_Action
  4. {
  5.  
  6.     public function errorAction()
  7.     {
  8.         $errors = $this->_getParam('error_handler');
  9.  
  10.         if (!$errors) {
  11.             $this->view->message = 'You have reached the error page';
  12.             return;
  13.         }
  14.  
  15.         switch ($errors->type) {
  16.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  17.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  18.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  19.  
  20.                 // 404 error -- controller or action not found
  21.                 $this->getResponse()->setHttpResponseCode(404);
  22.                 $this->view->message = 'Page not found';
  23.                 break;
  24.             default:
  25.                 // application error
  26.                 $this->getResponse()->setHttpResponseCode(500);
  27.                 $this->view->message = 'Application error';
  28.                 break;
  29.         }
  30.  
  31.         // Log exception, if logger available
  32.         if ($log = $this->getLog()) {
  33.             $log->crit($this->view->message, $errors->exception);
  34.         }
  35.  
  36.         // conditionally display exceptions
  37.         if ($this->getInvokeArg('displayExceptions') == true) {
  38.             $this->view->exception = $errors->exception;
  39.         }
  40.  
  41.         $this->view->request   = $errors->request;
  42.     }
  43.  
  44.     public function getLog()
  45.     {
  46.         $bootstrap = $this->getInvokeArg('bootstrap');
  47.         if (!$bootstrap->hasResource('Log')) {
  48.             return false;
  49.         }
  50.         $log = $bootstrap->getResource('Log');
  51.         return $log;
  52.     }
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement