From 37caffb6bc73a2b5865c829ced38a2e11cac1508 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 6 Jun 2016 16:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0HTTP=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=AE=9A=E5=90=91=E9=A1=B5=E9=9D=A2=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=20=E5=A2=9E=E5=8A=A0=20http=5Fexception=5Furl=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/exception/Handle.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/library/think/exception/Handle.php b/library/think/exception/Handle.php index 354c6596..a4737fc3 100644 --- a/library/think/exception/Handle.php +++ b/library/think/exception/Handle.php @@ -42,13 +42,13 @@ class Handle 'message' => $exception->getMessage(), 'code' => $this->getCode($exception), ]; - $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; + $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; } else { $data = [ 'code' => $exception->getCode(), 'message' => $exception->getMessage(), ]; - $log = "[{$data['code']}]{$data['message']}"; + $log = "[{$data['code']}]{$data['message']}"; } Log::record($log, 'error'); @@ -62,7 +62,6 @@ class Handle return true; } } - return false; } @@ -82,7 +81,7 @@ class Handle } /** - * @param $output + * @param Output $output * @param Exception $e */ public function renderForConsole(Output $output, Exception $e) @@ -92,15 +91,17 @@ class Handle /** * @param HttpException $e - * @return \think\Response + * @return Response */ protected function renderHttpException(HttpException $e) { $status = $e->getStatusCode(); - - //TODO 根据状态码自动输出错误页面 - - return $this->convertExceptionToResponse($e); + $error = Config::get('http_exception_url'); + if (!APP_DEBUG && !empty($error[$status])) { + return Response::create($error[$status], 'redirect')->send(); + } else { + return $this->convertExceptionToResponse($e); + } } /**