AsUpdateConflict returns the parsed conflict details when this APIError carries them, or nil otherwise. Returns nil for any error other than "update_conflict" so callers can branch cleanly.
()
| 1184 | // carries them, or nil otherwise. Returns nil for any error other than |
| 1185 | // "update_conflict" so callers can branch cleanly. |
| 1186 | func (e *APIError) AsUpdateConflict() *UpdateConflictDetails { |
| 1187 | if e == nil || e.Code != "update_conflict" || len(e.Details) == 0 { |
| 1188 | return nil |
| 1189 | } |
| 1190 | var d UpdateConflictDetails |
| 1191 | if err := json.Unmarshal(e.Details, &d); err != nil { |
| 1192 | return nil |
| 1193 | } |
| 1194 | return &d |
| 1195 | } |
| 1196 | |
| 1197 | // WriteUpdateConflictError formats an optimistic-concurrency conflict to w in |
| 1198 | // the canonical two-track shape (TASK-2022), mirroring WriteOpenChildrenError |