refactor(dify): 优化 Dify 相关接口异常处理- 在 messages 方法中使用 ExceptionUtil.difyException() 包装异常处理

- 在 deleteConversation 方法中添加异常捕获,抛出更具体的 RuntimeException
This commit is contained in:
zhuangtianxiang 2025-05-15 20:48:45 +08:00
parent 73d3a38ad0
commit eb134a034d

View File

@ -106,7 +106,7 @@ public class V1ChatController {
) {
String apiKey = appEntityService.getApikey(appid);
request.setApiKey(apiKey);
return difyChat.messages(request);
return ExceptionUtil.difyException(()->difyChat.messages(request));
}
/**
@ -133,7 +133,11 @@ public class V1ChatController {
public void deleteConversation(@RequestParam String conversationId, @RequestParam String appId) {
String apiKey = appEntityService.getApikey(appId);
String userId = SecurityUtil.getUserInfo().id.toString();
difyChat.deleteConversation(conversationId, apiKey,userId);
try{
difyChat.deleteConversation(conversationId, apiKey,userId);
}catch (RuntimeException e){
throw new RuntimeException("删除会话失败"+e.getMessage());
}
}
/**