ClassifyError maps an MCP error to a low-cardinality error.type value. MCP errors are often plain RPC errors; this helper picks reasonable labels for cancellation and falls back to the type name otherwise.
(err error)
| 234 | // MCP errors are often plain RPC errors; this helper picks reasonable |
| 235 | // labels for cancellation and falls back to the type name otherwise. |
| 236 | func ClassifyError(err error) string { |
| 237 | if err == nil { |
| 238 | return "" |
| 239 | } |
| 240 | switch { |
| 241 | case errors.Is(err, context.Canceled): |
| 242 | return "context_canceled" |
| 243 | case errors.Is(err, context.DeadlineExceeded): |
| 244 | return "deadline_exceeded" |
| 245 | } |
| 246 | return "rpc_error" |
| 247 | } |
no outgoing calls