* 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
最佳答案