From 79863215b33babf5bcd047ed2d8159ffe31e894a Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Sun, 15 Dec 2019 13:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/base/CatchRequest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extend/catcher/base/CatchRequest.php b/extend/catcher/base/CatchRequest.php index fd2668f..e1a0fca 100644 --- a/extend/catcher/base/CatchRequest.php +++ b/extend/catcher/base/CatchRequest.php @@ -2,6 +2,7 @@ namespace catcher\base; use app\Request; +use catcher\exceptions\FailedException; use catcher\exceptions\ValidateFailedException; use think\Validate; @@ -27,10 +28,14 @@ class CatchRequest extends Request */ protected function validate() { - $validate = new Validate(); + try { + $validate = new Validate(); - if (!$validate->check(request()->param(), $this->rules())) { - throw new ValidateFailedException($validate->getError()); + if (!$validate->check(request()->param(), $this->rules())) { + throw new FailedException($validate->getError()); + } + } catch (\Exception $e) { + throw new ValidateFailedException($e->getMessage()); } return true;