From f83eecb853a9b8a875095ada09a6b8ff1aa9413c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 10 Dec 2015 22:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=BC=82=E5=B8=B8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/error.php | 15 ++++++-------- tpl/think_exception.tpl | 44 ++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/library/think/error.php b/library/think/error.php index 51063eeb..bb0e2487 100644 --- a/library/think/error.php +++ b/library/think/error.php @@ -98,7 +98,8 @@ class Error { $message = is_array($error) ? $error['message'] : $error; $code = is_array($error) ? $error['code'] : $code; - $e = []; + + $e = ['mssage' => $message, 'code' => $code]; if (APP_DEBUG) { //调试模式下输出错误信息 if (!is_array($error)) { @@ -112,26 +113,22 @@ class Error } else { $e = $error; } - } else { + } elseif (!IS_API) { //否则定向到错误页面 $error_page = Config::get('error_page'); if (!empty($error_page)) { header('Location: ' . $error_page); } else { - if (Config::get('show_error_msg')) { - $e['message'] = is_array($error) ? $error['message'] : $error; - } else { - $e['message'] = Config::get('error_message'); - } + $e['message'] = Config::get('show_error_msg') ? $message : Config::get('error_message'); } } $type = Config::get('default_return_type'); - if ('html' == $type) { + if (!IS_API && 'html' == $type) { include Config::get('exception_tmpl'); } else { // 异常信息输出监听 - Hook::listen('error_output', $e); + APP_HOOK && Hook::listen('error_output', $e); // 输出异常内容 Response::returnData($e, $type); } diff --git a/tpl/think_exception.tpl b/tpl/think_exception.tpl index 84b27e97..56b66571 100644 --- a/tpl/think_exception.tpl +++ b/tpl/think_exception.tpl @@ -5,18 +5,18 @@ @@ -25,29 +25,29 @@ h1{ font-size: 32px; line-height: 48px; }

-
-
-

错误位置

-
-
-

FILE:  LINE:

-
+
+
+

错误位置

+
+

FILE:  LINE:

+
+
-
-
-

TRACE

-
-
-

-
+
+
+

TRACE

+
+

+
+
\ No newline at end of file