Files
kandev/apps/backend/internal/mcp/server/backend_error.go
T
2026-09-15 23:13:33 +01:00

23 lines
569 B
Go

package mcp
import "fmt"
// BackendError preserves a structured WebSocket error for MCP tool handlers.
// Details may contain a committed partial result and must remain available to
// callers that can recover from an independent provider failure.
type BackendError struct {
Code string
Message string
Details map[string]interface{}
}
func (e *BackendError) Error() string {
if e == nil {
return "backend error"
}
if e.Code == "" {
return fmt.Sprintf("backend error: %s", e.Message)
}
return fmt.Sprintf("backend error [%s]: %s", e.Code, e.Message)
}