Exemplo n.º 1
0
 /**
  * 全局异常处理
  * 异常有两个来源
  * 1. 通过set_exception_handler设置的全局未捕获异常
  * 2. 通过Core_App::dispatch()捕获的异常
  * @param  [type] $e [description]
  * @return [type]    [description]
  */
 public function handleException($e)
 {
     $controller = Core_App::getInstance()->controllerObj;
     $isBaseExp = $e instanceof Exception_Base;
     $info = array('exp' => get_class($e), 'code' => $e->getCode(), 'msg' => $e->getMessage(), 'expParams' => $isBaseExp ? $e->getParams() : null, 'line' => sprintf('%s:%d', $e->getFile(), $e->getLine()), 'uri' => Comm_Context::getServer('REQUEST_URI'), 'elapse' => sprintf('%.3f', microtime(true) - SYSTEM_START_TIME), 'reqParams' => empty($controller) ? null : $controller->getParams());
     Tool_Log::error('request exception, ' . Tool_Json::encode($info));
     if ($isBaseExp) {
         // 异常自身处理过程
         $e->handle();
     } else {
         // 默认异常处理过程
         $a = new Exception_Base();
         $a->__real__ = $e;
         $a->handle();
     }
 }
Exemplo n.º 2
0
 /**
  * @param Exception_Base $e
  *
  * @throws Exception_Base
  * @return $this
  */
 public function error_page($e)
 {
     $this->view = $e->getTemplate();
     $this->template_data['title'] = __('common.error');
     $this->flash_error($e->getMessage());
 }