You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace a strings.HasPrefix + strings.Cut with a call to strings.CutPrefix.
- Instead of enumerating all possible redirection code, check if the code is
300-something.
- Extract an error constructor outside of its current scope instead of
duplicating it 5 times
- Use constant strings for LocalizedError's return values where possible.
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: access forbidden (403 status code)"), "error.http_forbidden")
198
192
casehttp.StatusTooManyRequests:
199
193
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: too many requests (429 status code)"), "error.http_too_many_requests")
200
-
casehttp.StatusNotFound, http.StatusGone:
201
-
returnlocale.NewLocalizedErrorWrapper(fmt.Errorf("fetcher: resource not found (%d status code)", r.httpResponse.StatusCode), "error.http_resource_not_found")
194
+
casehttp.StatusNotFound:
195
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: resource not found (404 status code)"), "error.http_resource_not_found")
196
+
casehttp.StatusGone:
197
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: resource not found (410 status code)"), "error.http_resource_not_found")
202
198
casehttp.StatusInternalServerError:
203
-
returnlocale.NewLocalizedErrorWrapper(fmt.Errorf("fetcher: remote server error (%d status code)", r.httpResponse.StatusCode), "error.http_internal_server_error")
199
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: remote server error (500 status code)"), "error.http_internal_server_error")
204
200
casehttp.StatusBadGateway:
205
-
returnlocale.NewLocalizedErrorWrapper(fmt.Errorf("fetcher: bad gateway (%d status code)", r.httpResponse.StatusCode), "error.http_bad_gateway")
201
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: bad gateway (502 status code)"), "error.http_bad_gateway")
206
202
casehttp.StatusServiceUnavailable:
207
-
returnlocale.NewLocalizedErrorWrapper(fmt.Errorf("fetcher: service unavailable (%d status code)", r.httpResponse.StatusCode), "error.http_service_unavailable")
203
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: service unavailable (503 status code)"), "error.http_service_unavailable")
208
204
casehttp.StatusGatewayTimeout:
209
-
returnlocale.NewLocalizedErrorWrapper(fmt.Errorf("fetcher: gateway timeout (%d status code)", r.httpResponse.StatusCode), "error.http_gateway_timeout")
205
+
returnlocale.NewLocalizedErrorWrapper(errors.New("fetcher: gateway timeout (504 status code)"), "error.http_gateway_timeout")
0 commit comments