AsAPIError returns the *APIError in err's chain, or nil. Use it instead of a direct err.(*APIError) assertion: a write that sent an op_key comes back wrapped in *OpKeyError (BUG-3999), which a direct assertion does not see through.
(err error)
| 3224 | // wrapped in *OpKeyError (BUG-3999), which a direct assertion does not see |
| 3225 | // through. |
| 3226 | func AsAPIError(err error) *APIError { |
| 3227 | var apiErr *APIError |
| 3228 | if errors.As(err, &apiErr) { |
| 3229 | return apiErr |
| 3230 | } |
| 3231 | return nil |
| 3232 | } |
| 3233 | |
| 3234 | // OpKeyError carries the idempotency key a failed write sent (BUG-3999), so |
| 3235 | // the root error writer can print it and a person or agent can re-run the |
no outgoing calls
no test coverage detected