mirror of https://github.com/containers/image.git
docker: expand use of UnexpectedHTTPStatusError
So that callers can actually check the status code of all requests if needed. This changes error text slightly but I think it still carries the same meaning. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
42e84b4128
commit
093536c0d6
|
|
@ -996,7 +996,7 @@ func (c *dockerClient) getExternalBlob(ctx context.Context, urls []string) (io.R
|
|||
continue
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
err := fmt.Errorf("error fetching external blob from %q: %d (%s)", u, resp.StatusCode, http.StatusText(resp.StatusCode))
|
||||
err := fmt.Errorf("error fetching external blob from %q: %w", u, newUnexpectedHTTPStatusError(resp))
|
||||
remoteErrors = append(remoteErrors, err)
|
||||
logrus.Debug(err)
|
||||
resp.Body.Close()
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ func (s *dockerImageSource) getOneSignature(ctx context.Context, sigURL *url.URL
|
|||
logrus.Debugf("... got status 404, as expected = end of signatures")
|
||||
return nil, true, nil
|
||||
} else if res.StatusCode != http.StatusOK {
|
||||
return nil, false, fmt.Errorf("reading signature from %s: status %d (%s)", sigURL.Redacted(), res.StatusCode, http.StatusText(res.StatusCode))
|
||||
return nil, false, fmt.Errorf("reading signature from %s: %w", sigURL.Redacted(), newUnexpectedHTTPStatusError(res))
|
||||
}
|
||||
|
||||
contentType := res.Header.Get("Content-Type")
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ func httpResponseToError(res *http.Response, context string) error {
|
|||
err := registryHTTPResponseToError(res)
|
||||
return ErrUnauthorizedForCredentials{Err: err}
|
||||
default:
|
||||
if context != "" {
|
||||
context += ": "
|
||||
if context == "" {
|
||||
return newUnexpectedHTTPStatusError(res)
|
||||
}
|
||||
return fmt.Errorf("%sinvalid status code from registry %d (%s)", context, res.StatusCode, http.StatusText(res.StatusCode))
|
||||
return fmt.Errorf("%s: %w", context, newUnexpectedHTTPStatusError(res))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue