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.
()
| 1384 | // carries them, or nil otherwise. Returns nil for any error other than |
| 1385 | // "plan_limit_exceeded" so callers can branch cleanly. |
| 1386 | func (e *APIError) AsPlanLimit() *PlanLimitDetails { |
| 1387 | if e == nil || e.Code != "plan_limit_exceeded" || len(e.Details) == 0 { |
| 1388 | return nil |
| 1389 | } |
| 1390 | var d PlanLimitDetails |
| 1391 | if err := json.Unmarshal(e.Details, &d); err != nil { |
| 1392 | return nil |
| 1393 | } |
| 1394 | return &d |
| 1395 | } |
| 1396 | |
| 1397 | // WritePlanLimitError formats a plan-limit rejection to w in the canonical |
| 1398 | // two-track shape (TASK-788): |
no outgoing calls
no test coverage detected