自定义handle类无法处理ThrowableError

浏览:1231 发布日期:2018/01/18 分类:求助交流
我的php版本是7.2javascript:;
这是自定义的handle类namespace app\index\exception;

use think\exception\Handle;
use think\exception\ThrowableError;
class ExceptionHandler extends Handle
{
    //http异常码
    private $code;
    //异常信息
    private $msg;
    //异常码
    private $err;

    public function render(\Exception $e){
        if($e instanceof BaseException){
            $this->code=$e->code;
            $this->msg=$e->msg;
            $this->err=$e->err;
            return json(['err'=>$this->err,'msg'=>$this->msg],$this->code);
        }else{
            parent::render($e);
        }
    }
}
我使用系统自带的handle可以处理ThrowableError

自定义的就报错Fatal error: Uncaught Error: Call to a member function send() on null in /opt/lampp/htdocs/thinkphp/library/think/Error.php on line 52

附件 图片1.png ( 51.28 KB 下载:1 次 )

最佳答案
评论( 相关
后面还有条评论,点击查看>>