这是自定义的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 次 )
最佳答案