Ejemplo n.º 1
0
 public function errorAction()
 {
     $error = $this->_getParam('error_handler');
     $this->view->error_code = $error_code = Khcn_Api::getErrorCode(true);
     // Handle missing pages
     switch ($error->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             return $this->_forward('notfound');
             break;
         default:
             break;
     }
     // Log this message
     if (isset($error->exception) && Zend_Registry::isRegistered('Zend_Log') && ($log = Zend_Registry::get('Zend_Log')) instanceof Zend_Log) {
         // Only log if in production or the exception is not an instance of Engine_Exception
         $e = $error->exception;
         if ('production' === APPLICATION_ENV || !$e instanceof Engine_Exception) {
             $output = '';
             $output .= PHP_EOL . 'Error Code: ' . $error_code . PHP_EOL;
             $output .= $e->__toString();
             $log->log($output, Zend_Log::CRIT);
         }
     }
     //$this->getResponse()->setRawHeader('HTTP/1.1 500 Internal server error');
     $this->view->status = false;
     $this->view->errorName = get_class($error->exception);
     if (APPLICATION_ENV != 'production') {
         if ($error->exception instanceof Exception) {
             $this->view->error = $error->exception->__toString();
         }
     } else {
         $this->view->message = Zend_Registry::get('Zend_Translate')->_('An error has occurred');
     }
 }