fix include TaskID in Error

This commit is contained in:
ye wang
2025-02-19 20:48:24 +08:00
parent 9992b47f36
commit daab9fdc68
2 changed files with 6 additions and 4 deletions
+1
View File
@@ -104,6 +104,7 @@ func (c *wsConn) handleEvent(event Event) (bool, error) {
return true, nil
case "task-failed":
event.Header.Error.RequestID = event.Header.TaskID
return true, fmt.Errorf("received task-failed event: %w", event.Header.Error)
}
return false, nil
+5 -4
View File
@@ -7,6 +7,7 @@ import (
type Header struct {
Action Action `json:"action"`
TaskID string `json:"task_id"`
Streaming string `json:"streaming"`
Event string `json:"event"`
Attributes map[string]interface{} `json:"attributes"`
@@ -14,13 +15,13 @@ type Header struct {
}
type Error struct {
TaskID string `json:"task_id"`
Code string `json:"error_code,omitempty"`
Message string `json:"error_message,omitempty"`
RequestID string `json:"request_id,omitempty"`
Code string `json:"error_code,omitempty"`
Message string `json:"error_message,omitempty"`
}
func (e Error) Error() string {
return fmt.Sprintf("code: %s, message: %s", e.Code, e.Message)
return fmt.Sprintf("request_id: %s, code: %s, message: %s", e.RequestID, e.Code, e.Message)
}
type Format string