fix(llm): 修复删除知识库文档时可能出现的空指针异常

- 在删除知识库文档的代码中添加了异常捕获处理
- 当删除操作失败时,记录错误日志并抛出自定义异常
- 优化了代码的健壮性,提高了系统稳定性
This commit is contained in:
sunxiqing 2025-03-10 09:48:17 +08:00
parent 2d6d0bffe3
commit 1ed9351fba

View File

@ -45,8 +45,13 @@ public class AsyncKnowledgeBase {
// 如果提供了 ids则删除现有的知识库文档
if (!CollectionUtils.isAnyEmpty(ids)) {
log.info("正在删除现有的知识库文档ids: {}", ids);
String mes = ragHttpService.ragDocumentsDel(llmBackendProperties.getRagDocumentsDel(), ids);
log.info("删除知识库信息: {}", mes);
try {
String mes = ragHttpService.ragDocumentsDel(llmBackendProperties.getRagDocumentsDel(), ids);
log.info("删除知识库信息: {}", mes);
} catch (Exception e) {
log.error("删除知识库信息失败: {}", e.getMessage());
throw exception(new ErrorCode(10047, "删除知识库信息失败!"));
}
} else {
log.info("未提供 ids跳过删除操作。");
}