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 @@ +