From 69352158bfd4de9bf95c66eefdf67a558a3a0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=A7=80=E9=92=A2?= Date: Wed, 2 Oct 2019 23:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E6=9C=89=E5=8A=A9=E4=BA=8E=E5=BC=80=E5=8F=91=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/util/ExceptionHandle.php | 24 ++++++++++++++++++++++++ config/app.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 application/util/ExceptionHandle.php diff --git a/application/util/ExceptionHandle.php b/application/util/ExceptionHandle.php new file mode 100644 index 0000000..c137683 --- /dev/null +++ b/application/util/ExceptionHandle.php @@ -0,0 +1,24 @@ + + */ + +namespace app\util; + +use Exception; +use think\exception\Handle; + +/** + * Class ExceptionHandle + * @package app\util + * 异常处理handle类 + * Detail see: https://www.kancloud.cn/manual/thinkphp5_1/354092 + */ +class ExceptionHandle extends Handle { + + public function render(Exception $e) { + return parent::render($e)->header(config('apiadmin.CROSS_DOMAIN')); + } +} diff --git a/config/app.php b/config/app.php index bde326a..d599a21 100644 --- a/config/app.php +++ b/config/app.php @@ -141,6 +141,6 @@ return [ // 显示错误信息 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle - 'exception_handle' => '', + 'exception_handle' => '\\app\\util\\ExceptionHandle', ];