Refactor error handling in services to use internationalized error messages
- Updated OSSStorage validation errors to use internationalized messages. - Changed error messages in provider.go for unsupported file storage types. - Refactored tag_service.go to replace hardcoded error messages with internationalized versions. - Updated ticket_service.go to use internationalized error messages for various validation checks. - Refactored ticket_tag_service.go to use internationalized error messages for tag validation. - Changed ticket_view_service.go to use internationalized error messages for view validation. - Updated tool_catalog_service.go to use internationalized error messages for tool code validation. - Refactored user_service.go to replace error messages with internationalized versions. - Updated ws_service.go to use internationalized error messages for WebSocket handling. - Refactored wxwork_kf_inbound_service.go to use internationalized error messages for message handling. - Updated wxwork_kf_outbound_service.go to use internationalized error messages for outbound message handling. - Refactored wxwork_login_service.go to use internationalized error messages for login handling. - Updated login.go in wxwork package to use internationalized error messages for login state and ticket validation.
This commit is contained in:
@@ -22,16 +22,16 @@ func init() {
|
||||
func DebugRunSkill(ctx context.Context, req request.SkillDebugRunRequest) (*response.SkillDebugRunResponse, error) {
|
||||
aiAgent := svc.AIAgentService.Get(req.AIAgentID)
|
||||
if aiAgent == nil || aiAgent.Status != enums.StatusOk {
|
||||
return nil, errorsx.InvalidParam("AI Agent不存在或未启用")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0007")
|
||||
}
|
||||
aiConfig := svc.AIConfigService.Get(aiAgent.AIConfigID)
|
||||
if aiConfig == nil {
|
||||
return nil, errorsx.InvalidParam("AI Agent关联的AI配置不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0008")
|
||||
}
|
||||
var conversation *models.Conversation
|
||||
if req.ConversationID > 0 {
|
||||
if conversation = svc.ConversationService.Get(req.ConversationID); conversation == nil {
|
||||
return nil, errorsx.InvalidParam("会话不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0116")
|
||||
}
|
||||
} else {
|
||||
conversation = &models.Conversation{ID: req.ConversationID, AIAgentID: req.AIAgentID}
|
||||
@@ -57,32 +57,32 @@ func DebugRunSkill(ctx context.Context, req request.SkillDebugRunRequest) (*resp
|
||||
func DebugResumeSkill(ctx context.Context, req request.SkillDebugResumeRequest) (*response.SkillDebugRunResponse, error) {
|
||||
aiAgent := svc.AIAgentService.Get(req.AIAgentID)
|
||||
if aiAgent == nil || aiAgent.Status != enums.StatusOk {
|
||||
return nil, errorsx.InvalidParam("AI Agent不存在或未启用")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0007")
|
||||
}
|
||||
aiConfig := svc.AIConfigService.Get(aiAgent.AIConfigID)
|
||||
if aiConfig == nil {
|
||||
return nil, errorsx.InvalidParam("AI Agent关联的AI配置不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0008")
|
||||
}
|
||||
pendingInterrupt := svc.ConversationInterruptService.GetByCheckPointID(strings.TrimSpace(req.CheckPointID))
|
||||
if pendingInterrupt == nil {
|
||||
return nil, errorsx.InvalidParam("CheckPoint 不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0014")
|
||||
}
|
||||
if pendingInterrupt.AIAgentID > 0 && pendingInterrupt.AIAgentID != req.AIAgentID {
|
||||
return nil, errorsx.InvalidParam("CheckPoint 与 AI Agent 不匹配")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0015")
|
||||
}
|
||||
conversationID := req.ConversationID
|
||||
if conversationID <= 0 {
|
||||
conversationID = pendingInterrupt.ConversationID
|
||||
}
|
||||
if conversationID <= 0 {
|
||||
return nil, errorsx.InvalidParam("会话不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0116")
|
||||
}
|
||||
conversation := svc.ConversationService.Get(conversationID)
|
||||
if conversation == nil {
|
||||
return nil, errorsx.InvalidParam("会话不存在")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0116")
|
||||
}
|
||||
if conversation.AIAgentID > 0 && conversation.AIAgentID != req.AIAgentID {
|
||||
return nil, errorsx.InvalidParam("会话与 AI Agent 不匹配")
|
||||
return nil, errorsx.InvalidParamI18n("error.e0117")
|
||||
}
|
||||
resumeText := strings.TrimSpace(req.UserMessage)
|
||||
summary, err := Service.Resume(ctx, applicationruntime.ResumeRequest{
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"agent-desk/internal/ai/mcps"
|
||||
impladapter "agent-desk/internal/ai/runtime/internal/impl/adapter"
|
||||
"agent-desk/internal/ai/runtime/registry"
|
||||
"agent-desk/internal/pkg/i18nx"
|
||||
"agent-desk/internal/pkg/toolx"
|
||||
|
||||
einotool "github.com/cloudwego/eino/components/tool"
|
||||
@@ -161,10 +162,10 @@ func (t *ToolSearchTool) invokeTargetTool(ctx context.Context, toolCode string,
|
||||
toolCode = strings.TrimSpace(toolCode)
|
||||
serverCode, toolName := toolx.SplitMCPToolCode(toolCode)
|
||||
if serverCode == "" || toolName == "" {
|
||||
return "", fmt.Errorf("tool_search 只支持调用 MCP toolCode")
|
||||
return "", i18nx.Errorf("error.e0077")
|
||||
}
|
||||
if !containsToolCode(t.allowedToolCodes, toolCode) {
|
||||
return "", fmt.Errorf("目标工具未被当前会话授权")
|
||||
return "", i18nx.Errorf("error.e0279")
|
||||
}
|
||||
result, err := mcps.Runtime.CallTool(ctx, serverCode, toolName, cloneArguments(arguments))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user