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.
()
| 3204 | // carries them, or nil otherwise. Returns nil for any error other than |
| 3205 | // "plan_limit_exceeded" so callers can branch cleanly. |
| 3206 | func (e *APIError) AsPlanLimit() *PlanLimitDetails { |
| 3207 | if e == nil || e.Code != "plan_limit_exceeded" || len(e.Details) == 0 { |
| 3208 | return nil |
| 3209 | } |
| 3210 | var d PlanLimitDetails |
| 3211 | if err := json.Unmarshal(e.Details, &d); err != nil { |
| 3212 | return nil |
| 3213 | } |
| 3214 | return &d |
| 3215 | } |
| 3216 | |
| 3217 | // WritePlanLimitError formats a plan-limit rejection to w in the canonical |
| 3218 | // two-track shape (TASK-788): |
no outgoing calls
no test coverage detected