使用Exception 和 HttpResponseException有什么区别?
来源:7-17 利用authbase处理登录拦截器

walk205
2020-07-08
public function show(...$args) {
throw new \think\Exception(...$args);
}
用这个抛出异常 Http.php里面也可以正常接收,不理解换成HttpResponseException反尔还要在Http.php里面多加个判断 是为什么?
写回答
1回答
-
walk205
提问者
2020-07-08
我在AuthBase里面验证完权限也是可以直接抛出异常
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
$this->accessToken = request()->header('access_token');
if(!$this->accessToken || !$this->isLogin()){
// return $this->show(config('message.error.login_not'), config('status.login_not'));
throw new \think\Exception(config('message.error.login_not'), config('status.login_not'));
}
}老师用HttpResponseException是有什么性能稳定上的考虑?
022020-10-07
相似问题