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)
| 1254 | // This mirrors WriteOpenChildrenError exactly in structure so the two paths |
| 1255 | // are easy to reason about together. |
| 1256 | func WritePlanLimitError(w io.Writer, apiErr *APIError) { |
| 1257 | envelope := map[string]any{ |
| 1258 | "error": map[string]any{ |
| 1259 | "code": apiErr.Code, |
| 1260 | "message": apiErr.Message, |
| 1261 | "details": apiErr.Details, |
| 1262 | }, |
| 1263 | } |
| 1264 | if data, err := json.Marshal(envelope); err == nil { |
| 1265 | fmt.Fprintln(w, StructuredErrorMarker+string(data)) |
| 1266 | } |
| 1267 | fmt.Fprintln(w, apiErr.Message) |
| 1268 | } |
| 1269 | |
| 1270 | // --- Attachments --- |
| 1271 | // |
no outgoing calls
no test coverage detected