400,'msg'=>$e->getError(),'data'=>[]])); } // 请求异常 if ($e instanceof HttpException && request()->isAjax()) { die(json_encode(['code'=>$e->getStatusCode(),'msg'=>$e->getMessage(),'data'=>[]])); } $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; //TODO::开发者对异常的操作 $input = file_get_contents("php://input"); $errData = [ 'requestUrl'=>$url, 'requestParam'=>['request'=>$_REQUEST,'input'=>@json_decode($input,true),'old_input'=>$input], 'msg'=>$e->getMessage(), 'line'=>$e->getLine(), 'path'=>$e->getFile(), ]; if(strpos($url, "debug=xiepeng123@")){ //可以在此交由系统处理 return parent::render($e); } $this->pushRedis($errData); die(json_encode((['msg'=>$e->getMessage(),'code'=>400,'data'=>[]]))); } public function pushRedis($data){ try { $request = Request::instance(); $data = [ "companyCode"=>"CHENSEN", "projectCode"=>"CSAPI", "requestUrl"=>$data['requestUrl'], "requestParam"=>$data['requestParam'], "msg"=>$data['msg'], "line"=>$data['line'], "path"=>$data['path'], "requestTime"=>microtime(true), "_client_ip_"=>$request->ip(0,true) ]; $redis = new \Redis(); $redis->connect('47.97.187.118', 6379,2); $redis->auth('gudong-hz'); $redis->rpush('email_list', json_encode($data)); }catch (\Exception $ex){ return true; } } }