isAjax()){ return json(['status'=>404,'msg'=>$e->getFunc().'方法不存在']); }else{ return response($e->getFunc().'控制器不存在', 404); } } //控制器不存在 if ($e instanceof ClassNotFoundException) { if($request->isAjax()){ return json(['status'=>404,'msg'=>$e->getClass().'控制器不存在']); }else{ return response($e->getClass().'控制器不存在', 404); } } //模板不存在 if ($e instanceof TemplateNotFoundException) { return response($e->getTemplate().'模板不存在', 404); } //验证器异常 if ($e instanceof ValidateException) { return json(['status'=>411,'msg'=>$e->getError()]); } //pdo异常 if ($e instanceof PDOException) { return response($e->getMessage(), 500); } //db异常 if ($e instanceof DbException) { return response($e->getMessage(), 500); } //error系统层面错误异常 if ($e instanceof ErrorException) { return response($e->getMessage(), 500); } // 请求异常 多为自定义的请求异常 if ($e instanceof HttpException) { Log::error('错误信息:'.print_r($e->getMessage(),true)); if($e->getStatusCode() == 500 && $this->error_log_db){ event('ExceptionLog', $e->getMessage()); } return json(['status'=>$e->getStatusCode(),'msg'=>$e->getMessage()]); } return parent::render($request, $e); } }