diff --git a/application/admin/request/FormRequest.php b/application/admin/request/FormRequest.php index 3a839d1..5eef447 100644 --- a/application/admin/request/FormRequest.php +++ b/application/admin/request/FormRequest.php @@ -6,7 +6,7 @@ */ namespace app\admin\request; -use think\exception\HttpException; +use think\exception\HttpResponseException; use think\Request; abstract class FormRequest extends Request @@ -20,7 +20,11 @@ abstract class FormRequest extends Request parent::__construct(); if ($this->withServer($_SERVER)->isAjax(true) && $err = $this->validate()) { - throw new HttpException(0, $err); + throw new HttpResponseException(json([ + 'code' => 0, + 'msg' => $err, + 'wait' => 3, + ])); } } } \ No newline at end of file diff --git a/application/exceptions/Handle.php b/application/exceptions/Handle.php deleted file mode 100644 index 25aadd5..0000000 --- a/application/exceptions/Handle.php +++ /dev/null @@ -1,44 +0,0 @@ -error($e->getMessage()); - break; - default: - return $this->convertExceptionToResponse($e); - break; - } - } - - protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = []) - { - return json([ - 'code' => 0, - 'msg' => $msg, - 'data' => $data, - 'url' => $url, - 'wait' => $wait, - ]); - } -} \ No newline at end of file diff --git a/config/app.php b/config/app.php index 4a26e13..c90a2dc 100644 --- a/config/app.php +++ b/config/app.php @@ -141,6 +141,6 @@ return [ // 显示错误信息 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle - 'exception_handle' => app\exceptions\Handle::class, + 'exception_handle' => '' ];