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)
| 3639 | // wrapped in *OpKeyError (BUG-3999), which a direct assertion does not see |
| 3640 | // through. |
| 3641 | func AsAPIError(err error) *APIError { |
| 3642 | var apiErr *APIError |
| 3643 | if errors.As(err, &apiErr) { |
| 3644 | return apiErr |
| 3645 | } |
| 3646 | return nil |
| 3647 | } |
| 3648 | |
| 3649 | // OpKeyError carries the idempotency key a failed write sent (BUG-3999), so |
| 3650 | // the root error writer can print it and a person or agent can re-run the |
no outgoing calls
no test coverage detected