MCPcopy Index your code
hub / github.com/docker/docker-agent / WrapHTTPError

Function WrapHTTPError

pkg/modelerrors/modelerrors.go:52–65  ·  view source on GitHub ↗

WrapHTTPError wraps err in a *StatusError carrying the HTTP status code and parsed Retry-After header from resp. Returns err unchanged if statusCode < 400 or err is nil. Pass resp=nil when no *http.Response is available.

(statusCode int, resp *http.Response, err error)

Source from the content-addressed store, hash-verified

50// parsed Retry-After header from resp. Returns err unchanged if statusCode < 400
51// or err is nil. Pass resp=nil when no *http.Response is available.
52func WrapHTTPError(statusCode int, resp *http.Response, err error) error {
53 if err == nil || statusCode < 400 {
54 return err
55 }
56 var retryAfter time.Duration
57 if resp != nil {
58 retryAfter = parseRetryAfterHeader(resp.Header.Get("Retry-After"))
59 }
60 return &StatusError{
61 StatusCode: statusCode,
62 RetryAfter: retryAfter,
63 Err: err,
64 }
65}
66
67// Default fallback configuration.
68const (

Callers 5

wrapGeminiErrorFunction · 0.92
wrapBedrockErrorFunction · 0.92
wrapAnthropicErrorFunction · 0.92
WrapOpenAIErrorFunction · 0.92
TestWrapHTTPErrorFunction · 0.85

Calls 2

parseRetryAfterHeaderFunction · 0.85
GetMethod · 0.65

Tested by 1

TestWrapHTTPErrorFunction · 0.68