TP6.0RC4异常getCode()无法取到值

浏览:534 发布日期:2019/08/19 分类:ThinkPHP6专区 关键字: ExceptionHandle,HttpException,Handle
/**
* Render an exception into an HTTP response.
*
* @access public
* @param \think\Request $request
* @param Throwable $e
* @return Response
*/
public function render($request, Throwable $e): Response
{
// 添加自定义异常处理机制
var_dump($e->getCode());// echo int(0)
// 其他错误交给系统处理
return parent::render($request, $e);
}
在模板输出,也是0

目前我用
'http_exception_template' => [
// 定义404错误的模板文件地址
404 => \think\facade\App::getRootPath() . 'view/error/json404.html',
// 还可以定义其它的HTTP status
500 => \think\facade\App::getRootPath() . 'view/error/json500.html',
]
虽然解决使用问题,但有没有能脱离模板、没能直接使用函数,希望官方能修正这个thinkPHP6.0 RC4bug
最佳答案
评论( 相关
后面还有条评论,点击查看>>