修改request

This commit is contained in:
wuyanwen 2019-12-15 13:38:25 +08:00
parent 6c12887f8d
commit 79863215b3

View File

@ -2,6 +2,7 @@
namespace catcher\base; namespace catcher\base;
use app\Request; use app\Request;
use catcher\exceptions\FailedException;
use catcher\exceptions\ValidateFailedException; use catcher\exceptions\ValidateFailedException;
use think\Validate; use think\Validate;
@ -27,10 +28,14 @@ class CatchRequest extends Request
*/ */
protected function validate() protected function validate()
{ {
try {
$validate = new Validate(); $validate = new Validate();
if (!$validate->check(request()->param(), $this->rules())) { if (!$validate->check(request()->param(), $this->rules())) {
throw new ValidateFailedException($validate->getError()); throw new FailedException($validate->getError());
}
} catch (\Exception $e) {
throw new ValidateFailedException($e->getMessage());
} }
return true; return true;