MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / newResponseStatusError

Function newResponseStatusError

fetcher/errors.go:80–103  ·  view source on GitHub ↗
(status int, body string)

Source from the content-addressed store, hash-verified

78}
79
80func newResponseStatusError(status int, body string) error {
81 var msg string
82
83 if len(body) > 0 {
84 msg = fmt.Sprintf("status: %d; %s", status, body)
85 } else {
86 msg = fmt.Sprintf("status: %d", status)
87 }
88
89 statusCode := 404
90 if status >= 400 && status < 500 {
91 statusCode = status
92 } else if status >= 500 {
93 statusCode = http.StatusBadGateway
94 }
95
96 return ResponseStatusError{errctx.NewTextError(
97 msg,
98 1,
99 errctx.WithStatusCode(statusCode),
100 errctx.WithPublicMessage(msgSourceIsUnreachable),
101 errctx.WithShouldReport(false),
102 )}
103}
104
105func newTooManyRedirectsError(n int) error {
106 return TooManyRedirectsError{errctx.NewTextError(

Callers 1

FetchMethod · 0.85

Calls 4

NewTextErrorFunction · 0.92
WithStatusCodeFunction · 0.92
WithPublicMessageFunction · 0.92
WithShouldReportFunction · 0.92

Tested by

no test coverage detected