Exemplo n.º 1
0
 /**
  * Exception Handler
  * @param  \Exception|\Throwable $e
  */
 public static function appException($e)
 {
     if (!$e instanceof \Exception) {
         $e = new ThrowableError($e);
     }
     self::getExceptionHandler()->report($e);
     if (\Norma\Support\Evn::isCli()) {
         //self::getExceptionHandler()->renderForConsole(new ConsoleOutput, $e);
     } else {
         self::getExceptionHandler()->render($e)->output();
     }
 }
Exemplo n.º 2
0
 /**
  * 获取错误信息
  * ErrorException则使用错误级别作为错误编码
  * @param  \Exception $exception
  * @return string                错误信息
  */
 protected function getMessage(Exception $exception)
 {
     $message = $exception->getMessage();
     if (\Norma\Support\Evn::isCli()) {
         return $message;
     }
     // 导入语言包
     if (Config::get('lang_switch')) {
         Lang::load(THINK_PATH . '/lang' . DS . Lang::detect() . EXT);
     }
     if (strpos($message, ':')) {
         $name = strstr($message, ':', true);
         return $message;
     } else {
         return $message;
     }
 }
Exemplo n.º 3
0
 /**
  * 当前的请求类型
  * @access public
  * @param bool $method  true 获取原始请求类型
  * @return string
  */
 public function method($method = false)
 {
     if (true === $method) {
         // 获取原始请求类型
         return \Norma\Support\Evn::isCli() ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
     } elseif (!$this->method) {
         if (isset($_POST[Config::get('var_method')])) {
             $this->method = strtoupper($_POST[Config::get('var_method')]);
         } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
             $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
         } else {
             $this->method = \Norma\Support\Evn::isCli() ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
         }
     }
     return $this->method;
 }