mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
fix:修改知识库相关错误码
This commit is contained in:
@@ -200,22 +200,11 @@ public interface ErrorCode {
|
||||
// 模型相关错误码
|
||||
int MODEL_PROVIDER_NOT_EXIST = 10162; // 供应器不存在
|
||||
|
||||
// 知识库数据集相关错误码
|
||||
// 知识库相关错误码
|
||||
int Knowledge_Base_RECORD_NOT_EXISTS = 10163; // 知识库记录不存在
|
||||
|
||||
// RAG配置相关错误码
|
||||
int RAG_CONFIG_NOT_FOUND = 10164; // RAG配置未找到
|
||||
int RAG_CONFIG_TYPE_ERROR = 10165; // RAG配置类型错误
|
||||
int RAG_DEFAULT_CONFIG_NOT_FOUND = 10166; // 默认RAG配置未找到
|
||||
int RAG_CONFIG_MISSING_PARAMS = 10167; // RAG配置缺少必要参数
|
||||
|
||||
// RAG API调用相关错误码
|
||||
int RAG_API_CREATE_FAILED = 10168; // RAG API创建数据集失败
|
||||
int RAG_API_UPDATE_FAILED = 10169; // RAG API更新数据集失败
|
||||
int RAG_API_DELETE_FAILED = 10170; // RAG API删除数据集失败
|
||||
|
||||
int UPLOAD_FILE_ERROR = 10171; // 上传文件失败
|
||||
int RAG_API_QUERY_FAILED = 10172; // RAG API查询失败
|
||||
int RAG_API_PARSE_FAILED = 10173; // RAG API解析失败
|
||||
int RAG_API_OPERATION_FAILED = 10174; // RAG API操作失败
|
||||
int UPLOAD_FILE_ERROR = 10168; // 上传文件失败
|
||||
}
|
||||
|
||||
+19
-21
@@ -213,7 +213,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
apiDeleteSuccess = true;
|
||||
} catch (Exception e) {
|
||||
log.error("删除RAGFlow数据集失败: {}", e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除RAGFlow数据集失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除RAGFlow数据集失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.warn("datasetId或ragModelId为空,跳过RAGFlow删除");
|
||||
@@ -396,7 +396,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
// 解析响应体,提取datasetId
|
||||
@@ -427,40 +427,39 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
} else {
|
||||
// 如果响应码不为0,说明API调用失败
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 响应内容: {}", code, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "RAGFlow API调用失败,响应码: " + code);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败,响应码: " + code);
|
||||
}
|
||||
|
||||
log.info("从RAGFlow API响应中解析出datasetId: {}", datasetId);
|
||||
log.debug("完整响应内容: {}", responseBody);
|
||||
} catch (Exception e) {
|
||||
log.error("解析RAGFlow API响应失败: {}, 响应内容: {}", e.getMessage(), responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(datasetId)) {
|
||||
log.error("无法从RAGFlow API响应中获取datasetId,响应内容: {}", responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "RAGFlow API响应中未包含datasetId");
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API响应中未包含datasetId");
|
||||
}
|
||||
|
||||
log.info("RAGFlow数据集创建成功,datasetId: {}", datasetId);
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"创建RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"创建RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "创建RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "创建RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("RAGFlow API调用失败 - 未知错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "创建RAGFlow数据集失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "创建RAGFlow数据集失败: " + e.getMessage());
|
||||
}
|
||||
return datasetId;
|
||||
}
|
||||
@@ -506,7 +505,7 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_UPDATE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
log.info("RAGFlow数据集更新成功,datasetId: {}", datasetId);
|
||||
@@ -514,19 +513,19 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_UPDATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"更新RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_UPDATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"更新RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_UPDATE_FAILED, "更新RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "更新RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("RAGFlow API调用失败 - 未知错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_UPDATE_FAILED, "更新RAGFlow数据集失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "更新RAGFlow数据集失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,27 +566,26 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
log.info("RAGFlow数据集删除成功,datasetId: {}", datasetId);
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"删除RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"删除RAGFlow数据集失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除RAGFlow数据集失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("RAGFlow API调用失败 - 未知错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除RAGFlow数据集失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除RAGFlow数据集失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+55
-55
@@ -102,7 +102,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
String responseBody = response.getBody();
|
||||
@@ -117,26 +117,26 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
return parseDocumentListResponse(dataObj, page, limit);
|
||||
} else {
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 响应内容: {}", code, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "RAGFlow API调用失败,响应码: " + code);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败,响应码: " + code);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档列表失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档列表失败: " + e.getMessage());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档列表失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档列表失败: " + e.getMessage());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档列表失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档列表失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("获取文档列表失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取文档列表失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取文档列表失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 获取文档列表操作结束 ===");
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取文档列表响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取文档列表响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取文档列表响应失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
String responseBody = response.getBody();
|
||||
@@ -393,30 +393,31 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
throw new RenException(ErrorCode.Knowledge_Base_RECORD_NOT_EXISTS);
|
||||
} else {
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 响应内容: {}", code, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "RAGFlow API调用失败,响应码: " + code);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败,响应码: " + code);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"解析RAGFlow响应失败: " + e.getMessage());
|
||||
} catch (HttpClientErrorException e) {
|
||||
if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||
log.warn("文档不存在,documentId: {}, datasetId: {}", documentId, datasetId);
|
||||
throw new RenException(ErrorCode.Knowledge_Base_RECORD_NOT_EXISTS);
|
||||
}
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档失败: " + e.getMessage());
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档失败: " + e.getMessage());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档失败: " + e.getMessage());
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档失败: " + e.getMessage());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("根据documentId获取文档失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "获取文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "获取文档失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 根据documentId获取文档操作结束 ===");
|
||||
}
|
||||
@@ -502,7 +503,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("删除文档失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除文档失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 根据documentId删除文档操作结束 ===");
|
||||
}
|
||||
@@ -720,44 +721,43 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
} else {
|
||||
// 如果响应码不为0,说明API调用失败
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 响应内容: {}", code, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "RAGFlow API调用失败,响应码: " + code);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败,响应码: " + code);
|
||||
}
|
||||
|
||||
log.info("从RAGFlow API响应中解析出documentId: {}", documentId);
|
||||
log.debug("完整响应内容: {}", responseBody);
|
||||
} catch (Exception e) {
|
||||
log.error("解析RAGFlow API响应失败: {}, 响应内容: {}", e.getMessage(), responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(documentId)) {
|
||||
log.error("无法从RAGFlow API响应中获取documentId,响应内容: {}", responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "RAGFlow API响应中未包含documentId");
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API响应中未包含documentId");
|
||||
}
|
||||
|
||||
log.info("RAGFlow文档上传成功,documentId: {},文档已开始自动解析切片", documentId);
|
||||
return documentId;
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"上传RAGFlow文档失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"上传RAGFlow文档失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "上传RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "上传RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("RAGFlow API调用失败 - 未知错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_CREATE_FAILED, "上传RAGFlow文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "上传RAGFlow文档失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -875,7 +875,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
} else {
|
||||
String message = (String) responseMap.get("message");
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 消息: {}", code, message);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "RAGFlow API调用失败: " + message);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败: " + message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("解析RAGFlow响应失败,但HTTP状态码成功,视为删除成功: {}", e.getMessage());
|
||||
@@ -888,25 +888,25 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
}
|
||||
} else {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"删除RAGFlow文档失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED,
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS,
|
||||
"删除RAGFlow文档失败: " + e.getMessage() + ", 响应: " + e.getResponseBodyAsString());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("RAGFlow API调用失败 - 未知错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_DELETE_FAILED, "删除RAGFlow文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "删除RAGFlow文档失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -987,7 +987,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
String responseBody = response.getBody();
|
||||
@@ -1003,26 +1003,26 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
} else {
|
||||
String message = (String) responseMap.get("message");
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 消息: {}, 响应内容: {}", code, message, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "RAGFlow API调用失败: " + message);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败: " + message);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "解析RAGFlow文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow文档失败: " + e.getMessage());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "解析RAGFlow文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow文档失败: " + e.getMessage());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "解析RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow文档失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("解析文档失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_PARSE_FAILED, "解析文档失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析文档失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 解析文档操作结束 ===");
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "列出切片失败");
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "列出切片失败");
|
||||
}
|
||||
|
||||
String responseBody = response.getBody();
|
||||
@@ -1109,26 +1109,26 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
} else {
|
||||
String message = (String) responseMap.get("message");
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 消息: {}, 响应内容: {}", code, message, responseBody);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "RAGFlow API调用失败: " + message);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败: " + message);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "列出切片失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "列出切片失败: " + e.getMessage());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "列出切片失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "列出切片失败: " + e.getMessage());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "列出切片失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "列出切片失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("列出切片失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_OPERATION_FAILED, "列出切片失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "列出切片失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 列出切片操作结束 ===");
|
||||
}
|
||||
@@ -1519,7 +1519,7 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
log.error("RAGFlow API调用失败,状态码: {}, 响应内容: {}", response.getStatusCode(), response.getBody());
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS);
|
||||
}
|
||||
|
||||
String responseBody = response.getBody();
|
||||
@@ -1537,31 +1537,31 @@ public class KnowledgeFilesServiceImpl implements KnowledgeFilesService {
|
||||
return result;
|
||||
} else {
|
||||
log.error("RAGFlow API响应格式错误,data字段不是Map类型: {}", dataObj);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "RAGFlow API响应格式错误");
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API响应格式错误");
|
||||
}
|
||||
} else {
|
||||
String message = (String) responseMap.get("message");
|
||||
log.error("RAGFlow API调用失败,响应码: {}, 错误信息: {}", code, message);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "RAGFlow API调用失败: " + message);
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "RAGFlow API调用失败: " + message);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("解析RAGFlow API响应失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "解析RAGFlow响应失败: " + e.getMessage());
|
||||
} catch (HttpClientErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - HTTP错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "召回测试失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "召回测试失败: " + e.getMessage());
|
||||
} catch (HttpServerErrorException e) {
|
||||
log.error("RAGFlow API调用失败 - 服务器错误: {}, 状态码: {}, 响应内容: {}",
|
||||
e.getMessage(), e.getStatusCode(), e.getResponseBodyAsString(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "召回测试失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "召回测试失败: " + e.getMessage());
|
||||
} catch (ResourceAccessException e) {
|
||||
log.error("RAGFlow API调用失败 - 网络连接错误: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "召回测试失败: 网络连接错误 - " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "召回测试失败: 网络连接错误 - " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("召回测试失败: {}", e.getMessage(), e);
|
||||
throw new RenException(ErrorCode.RAG_API_QUERY_FAILED, "召回测试失败: " + e.getMessage());
|
||||
throw new RenException(ErrorCode.RAG_CONFIG_MISSING_PARAMS, "召回测试失败: " + e.getMessage());
|
||||
} finally {
|
||||
log.info("=== 召回测试操作结束 ===");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user