From 0553c87a95b1d5b33d14ccb49bc5ea5351b27ca6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 11 Aug 2016 18:22:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E7=B3=BB=E7=BB=9F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E8=AF=AD=E8=A8=80=E5=8C=85=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/zh-cn.php | 1 + library/think/exception/Handle.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lang/zh-cn.php b/lang/zh-cn.php index 98abf7a0..2e1247f9 100644 --- a/lang/zh-cn.php +++ b/lang/zh-cn.php @@ -17,6 +17,7 @@ return [ 'Parse error' => '语法解析错误', 'Type error' => '类型错误', 'Fatal error' => '致命错误', + 'syntax error' => '语法错误', // 框架核心错误提示 'dispatch type not support' => '不支持的调度类型', diff --git a/library/think/exception/Handle.php b/library/think/exception/Handle.php index 3447c6a9..0b1f6bc0 100644 --- a/library/think/exception/Handle.php +++ b/library/think/exception/Handle.php @@ -14,7 +14,6 @@ namespace think\exception; use Exception; use think\App; use think\Config; -use think\Console; use think\console\Output; use think\Lang; use think\Log; @@ -44,13 +43,13 @@ class Handle 'message' => $this->getMessage($exception), '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' => $this->getCode($exception), 'message' => $this->getMessage($exception), ]; - $log = "[{$data['code']}]{$data['message']}"; + $log = "[{$data['code']}]{$data['message']}"; } Log::record($log, 'error'); @@ -210,11 +209,15 @@ class Handle } if (strpos($message, ':')) { - $name = strstr($message, ':', true); - return Lang::has($name) ? Lang::get($name) . ' ' . strstr($message, ':') : $message; - } else { - return Lang::has($message) ? Lang::get($message) : $message; + $name = strstr($message, ':', true); + $message = Lang::has($name) ? Lang::get($name) . strstr($message, ':') : $message; + } elseif (strpos($message, ',')) { + $name = strstr($message, ',', true); + $message = Lang::has($name) ? Lang::get($name) . ':' . substr(strstr($message, ','), 1) : $message; + } elseif (Lang::has($message)) { + $message = Lang::get($message); } + return $message; } /**