From 83d0a98b6a9e9567e7c98c39aa48ab2fb94ac473 Mon Sep 17 00:00:00 2001 From: Devil Date: Wed, 21 Jul 2021 15:18:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=8D=E7=BD=AE=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/tpl/think_exception.tpl | 535 ++++++++++++++++++++++++++++++++++++ config/app.php | 2 +- 2 files changed, 536 insertions(+), 1 deletion(-) create mode 100644 app/tpl/think_exception.tpl diff --git a/app/tpl/think_exception.tpl b/app/tpl/think_exception.tpl new file mode 100644 index 000000000..519cc19ce --- /dev/null +++ b/app/tpl/think_exception.tpl @@ -0,0 +1,535 @@ +'.end($names).''; + } +} + +if (!function_exists('parse_file')) { + function parse_file($file, $line) + { + return ''.basename($file)." line {$line}".''; + } +} + +if (!function_exists('parse_args')) { + function parse_args($args) + { + $result = []; + foreach ($args as $key => $item) { + switch (true) { + case is_object($item): + $value = sprintf('object(%s)', parse_class(get_class($item))); + break; + case is_array($item): + if (count($item) > 3) { + $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3))); + } else { + $value = sprintf('[%s]', parse_args($item)); + } + break; + case is_string($item): + if (strlen($item) > 20) { + $value = sprintf( + '\'%s...\'', + htmlentities($item), + htmlentities(substr($item, 0, 20)) + ); + } else { + $value = sprintf("'%s'", htmlentities($item)); + } + break; + case is_int($item): + case is_float($item): + $value = $item; + break; + case is_null($item): + $value = 'null'; + break; + case is_bool($item): + $value = '' . ($item ? 'true' : 'false') . ''; + break; + case is_resource($item): + $value = 'resource'; + break; + default: + $value = htmlentities(str_replace("\n", '', var_export(strval($item), true))); + break; + } + + $result[] = is_int($key) ? $value : "'{$key}' => {$value}"; + } + + return implode(', ', $result); + } +} +if (!function_exists('echo_value')) { + function echo_value($val) + { + if (is_array($val) || is_object($val)) { + echo htmlentities(json_encode($val, JSON_PRETTY_PRINT)); + } elseif (is_bool($val)) { + echo $val ? 'true' : 'false'; + } elseif (is_scalar($val)) { + echo htmlentities($val); + } else { + echo 'Resource'; + } + } +} +?> + + + + + 系统发生错误 + + + + + + $trace) { ?> +
+
+
+
+

+
+

+
+
+ +
+
    $value) { ?>
  1. ">
+
+ +
+

Call Stack

+
    +
  1. + +
  2. + +
  3. + +
+
+
+ + +
+

+
+ + + +
+

Exception Datas

+ $value) { ?> + + + + + + + $val) { ?> + + + + + + + +
empty
+ +
+ + + +
+

Environment Variables

+ $value) { ?> + + + + + + + $val) { ?> + + + + + + + +
empty
+ +
+ + + + + + + + + + + + + diff --git a/config/app.php b/config/app.php index d4c08edc5..80d5cc7b4 100644 --- a/config/app.php +++ b/config/app.php @@ -32,7 +32,7 @@ return [ 'deny_app_list' => [], // 异常页面的模板文件 - 'exception_tmpl' => ROOT . 'tpl/think_exception.tpl', + 'exception_tmpl' => APP_PATH . 'tpl/think_exception.tpl', // 错误显示信息,非调试模式有效 'error_message' => '系统出现错误、请联系管理员或到'.implode('', ['S','h','o','p','X','O']).'社区查阅~',