Is supports errors.Is(*HTTPError, ErrHTTPNotFound). The 500-with-text branch is a transitional fallback for /models/jobs/:uuid which today returns a 500 carrying "could not find any status for ID" instead of a proper 404. Drop the branch when the server is fixed.
(target error)
| 69 | // returns a 500 carrying "could not find any status for ID" instead of a |
| 70 | // proper 404. Drop the branch when the server is fixed. |
| 71 | func (e *HTTPError) Is(target error) bool { |
| 72 | if target != ErrHTTPNotFound { |
| 73 | return false |
| 74 | } |
| 75 | if e.StatusCode == http.StatusNotFound { |
| 76 | return true |
| 77 | } |
| 78 | return e.StatusCode == http.StatusInternalServerError && strings.Contains(e.Body, "could not find") |
| 79 | } |
| 80 | |
| 81 | // ---- HTTP helpers ---- |
| 82 |