AsPlanLimit returns the parsed plan-limit details when this APIError carries them, or nil otherwise. Returns nil for any error other than "plan_limit_exceeded" so callers can branch cleanly.
()
| 1282 | // carries them, or nil otherwise. Returns nil for any error other than |
| 1283 | // "plan_limit_exceeded" so callers can branch cleanly. |
| 1284 | func (e *APIError) AsPlanLimit() *PlanLimitDetails { |
| 1285 | if e == nil || e.Code != "plan_limit_exceeded" || len(e.Details) == 0 { |
| 1286 | return nil |
| 1287 | } |
| 1288 | var d PlanLimitDetails |
| 1289 | if err := json.Unmarshal(e.Details, &d); err != nil { |
| 1290 | return nil |
| 1291 | } |
| 1292 | return &d |
| 1293 | } |
| 1294 | |
| 1295 | // WritePlanLimitError formats a plan-limit rejection to w in the canonical |
| 1296 | // two-track shape (TASK-788): |
no outgoing calls
no test coverage detected