From a859e98207213bc4400817cf194f5bf937e55129 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Thu, 27 Aug 2020 16:18:09 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=9C=AA=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchExceptionHandle.php | 5 +++++ extend/catcher/middlewares/JsonResponseMiddleware.php | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 extend/catcher/middlewares/JsonResponseMiddleware.php diff --git a/extend/catcher/CatchExceptionHandle.php b/extend/catcher/CatchExceptionHandle.php index 3f068ee..dfdacd5 100644 --- a/extend/catcher/CatchExceptionHandle.php +++ b/extend/catcher/CatchExceptionHandle.php @@ -56,6 +56,11 @@ class CatchExceptionHandle extends Handle $e = new FailedException($e->getMessage(), 10005, $e); } + // 类型错误 + if ($e instanceof \TypeError) { + $e = new FailedException($e->getMessage(), 10005, $e); + } + return parent::render($request, $e); } diff --git a/extend/catcher/middlewares/JsonResponseMiddleware.php b/extend/catcher/middlewares/JsonResponseMiddleware.php new file mode 100644 index 0000000..ef90e0a --- /dev/null +++ b/extend/catcher/middlewares/JsonResponseMiddleware.php @@ -0,0 +1,10 @@ +