【发布时间】:2016-04-21 11:28:39
【问题描述】:
我试图了解何时引发验证异常。当我的自定义请求规则方法验证失败时,$e instanceof ValidationException 返回 false,$e instanceof HttpResponseException 返回 true,当我在 HttpResponseException 上 return $e->getResponse 时,它确实返回了所需的字段,因此当我的自定义请求验证失败时它会特别触发。我注意到在 Illuminate\Foundation\Exceptions\Handler 类中,渲染方法有声明 elseif ($e instanceof ValidationException && $e->getResponse()) 但它没有被执行,因为 HttpResponseException 是第一个在规则方法验证失败时触发的。所以我有点困惑。
【问题讨论】:
标签: php laravel laravel-5.2