WritePlanLimitError formats a plan-limit rejection to w in the canonical two-track shape (TASK-788): 1. A single `pad-structured-error/v1: {json}\n` marker line — consumed by the MCP stdio classifier so it lifts the structured payload instead of falling through to a generic server_error. 2. A human
(w io.Writer, apiErr *APIError)
| 1303 | // This mirrors WriteOpenChildrenError exactly in structure so the two paths |
| 1304 | // are easy to reason about together. |
| 1305 | func WritePlanLimitError(w io.Writer, apiErr *APIError) { |
| 1306 | envelope := map[string]any{ |
| 1307 | "error": map[string]any{ |
| 1308 | "code": apiErr.Code, |
| 1309 | "message": apiErr.Message, |
| 1310 | "details": apiErr.Details, |
| 1311 | }, |
| 1312 | } |
| 1313 | if data, err := json.Marshal(envelope); err == nil { |
| 1314 | fmt.Fprintln(w, StructuredErrorMarker+string(data)) |
| 1315 | } |
| 1316 | fmt.Fprintln(w, apiErr.Message) |
| 1317 | } |
| 1318 | |
| 1319 | // --- Attachments --- |
| 1320 | // |
no outgoing calls
no test coverage detected