利用thinkphp5.1x做接口开发,做一个全局异常的处理层.
class ExceptionHandler extends Handle {
private $code;
private $msg;
private $errCode;
public function render(\Exception $e)
{
if($e instanceof BaseException){
// 自定义的异常
$this->code=$e->code;
$this->msg=$e->msg;
$this->errCode=$e->errCode;
}else{
// 系统的异常,判断是不是调试模式:是,显示tp5的异常,否则显示封装接口的异常
if(config('app.app_debug')){
//使用系统的错误提示
parent::render();
}else{
$this->code=500;
$this->msg='服务器内部错误';
$this->errCode=999;
//写入日志
}
}
我输入一个错误的路由:显示了一个致命错误
为啥没有捕获到异常,我需要怎么修改我的代码了?
已解决
return parent::render($e);
上面没有把参数传递进去