示例#1
0
文件: Error.php 项目: cipherpols/cze
 /**
  * Does handle exception logic, e.g. logging them, disabling view,
  * passing info to view etc. pp.
  *
  * @param Exception $exception
  */
 protected function _handleException(Exception $exception)
 {
     $logMessage = Application\Error::toString($exception);
     Application::getLog()->crit($logMessage);
     // Are we in cli mode?
     if ('cli' === strtolower(PHP_SAPI)) {
         $this->disableView();
         return;
     }
     // Is that a user readable exception?
     if ($exception instanceof Exception) {
         $this->view->message = $logMessage;
         return;
     }
 }
示例#2
0
 /**
  * Handle errors and exceptions
  *
  * If the 'noErrorHandler' front controller flag has been set, returns early.
  *
  * @return void
  */
 protected function _handleError()
 {
     if ($this->isInsideErrorHandlerLoop) {
         return;
     }
     $response = $this->getResponse();
     // check for an exception
     if ($response->isException()) {
         $this->isInsideErrorHandlerLoop = true;
         // Get exception information
         $exceptions = $response->getException();
         $exception = $exceptions[0];
         if ($exception instanceof \Exception) {
             $message = Error::toString($exception);
             $log = \Zend_Registry::get('log');
             $log->crit($message);
             fputs(STDERR, $message);
         }
     }
 }
示例#3
0
文件: Base.php 项目: cipherpols/cze
 /**
  * Runs MVC Application
  * @return void
  * @throws \Exception
  */
 public function run()
 {
     if (self::isInCliCall()) {
         $this->runCli();
         return;
     }
     \Zend_Registry::set(Constants::CZE_APPLICATION, static::$instance);
     $this->init();
     static::getRouter();
     try {
         /* @var \Zend_Controller_Front $front */
         $front = static::getFrontController();
         if ($front) {
             if (isset($_SERVER['REQUEST_URI'])) {
                 if (preg_match('#^/api/#', $_SERVER['REQUEST_URI']) === 1) {
                     $this->routeToApi($front);
                 }
             }
             $front->dispatch();
         }
     } catch (\Exception $e) {
         Application::getLog()->crit(Error::toString($e));
         if (APPLICATION_ENV === Constants::ENV_DEVELOPMENT) {
             throw $e;
         }
     }
 }
示例#4
0
 /**
  * Initializes the Error Handler
  *
  * @return Error
  */
 protected static function initErrorHandler()
 {
     $errorHandler = new Error();
     $errorHandler->register();
     return $errorHandler;
 }