IsDocNotFoundError returns true if an error is a doc-not-found error
(err error)
| 222 | |
| 223 | // IsDocNotFoundError returns true if an error is a doc-not-found error |
| 224 | func IsDocNotFoundError(err error) bool { |
| 225 | if err == nil { |
| 226 | return false |
| 227 | } |
| 228 | if errors.Is(err, ErrNotFound) { |
| 229 | return true |
| 230 | } |
| 231 | |
| 232 | if errors.Is(err, gocb.ErrDocumentNotFound) { |
| 233 | return true |
| 234 | } |
| 235 | |
| 236 | var missingError sgbucket.MissingError |
| 237 | if errors.As(err, &missingError) { |
| 238 | return true |
| 239 | } |
| 240 | unwrappedErr := pkgerrors.Cause(err) |
| 241 | |
| 242 | switch unwrappedErr := unwrappedErr.(type) { |
| 243 | case *gomemcached.MCResponse: |
| 244 | return unwrappedErr.Status == gomemcached.KEY_ENOENT || unwrappedErr.Status == gomemcached.NOT_STORED |
| 245 | case *HTTPError: |
| 246 | return unwrappedErr.Status == http.StatusNotFound |
| 247 | default: |
| 248 | return false |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | // IsTemporaryKvError returns true if a kv operation has an error that is likely to be ephemeral. This represents |
| 253 | // situations where Couchbase Server is under load and would be expected to return a success or failure in a future call. |
no outgoing calls