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.
()
| 1233 | // carries them, or nil otherwise. Returns nil for any error other than |
| 1234 | // "plan_limit_exceeded" so callers can branch cleanly. |
| 1235 | func (e *APIError) AsPlanLimit() *PlanLimitDetails { |
| 1236 | if e == nil || e.Code != "plan_limit_exceeded" || len(e.Details) == 0 { |
| 1237 | return nil |
| 1238 | } |
| 1239 | var d PlanLimitDetails |
| 1240 | if err := json.Unmarshal(e.Details, &d); err != nil { |
| 1241 | return nil |
| 1242 | } |
| 1243 | return &d |
| 1244 | } |
| 1245 | |
| 1246 | // WritePlanLimitError formats a plan-limit rejection to w in the canonical |
| 1247 | // two-track shape (TASK-788): |
no outgoing calls
no test coverage detected