ajax()){ // 将方法拦截到自己的ExceptionReport $reporter = ExceptionReport::make($exception); if ($reporter->shouldReturn()){ return $reporter->report(); } if(env('APP_DEBUG')){ //开发环境,则显示详细错误信息 return parent::render($request, $exception); }else{ //线上环境,未知错误,则显示500 return $reporter->prodReport(); } } return parent::render($request, $exception); } }