correctCancelError will return the correct error for a canceled context. This is because rego changes a canceled context to a topdown.CancelErr. This error is not helpful if the code is "canceled". To make the error conform with the rest of our canceled errors, we will convert the error to a context
(err error)
| 119 | // error. No good information is lost, as the topdown.CancelErr provides the |
| 120 | // location of the query that was canceled, which does not matter. |
| 121 | func correctCancelError(err error) error { |
| 122 | e := new(topdown.Error) |
| 123 | if xerrors.As(err, &e) || e.Code == topdown.CancelErr { |
| 124 | return context.Canceled |
| 125 | } |
| 126 | return err |
| 127 | } |