Exemple #1
0
 /**
  * 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;
     }
 }
Exemple #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);
         }
     }
 }
Exemple #3
0
 /**
  * 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;
         }
     }
 }
Exemple #4
0
 /**
  * Initializes the Error Handler
  *
  * @return Error
  */
 protected static function initErrorHandler()
 {
     $errorHandler = new Error();
     $errorHandler->register();
     return $errorHandler;
 }