Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: common/lhttp/client.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/errors/walk_test.go ('k') | common/runtime/profiling/profiler.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/lhttp/client.go
diff --git a/common/lhttp/client.go b/common/lhttp/client.go
index e75f66613d3c42f84b69b3d39f352b01e51da746..0d0dc2970568a7292bd8b753724c924bab4a4baf 100644
--- a/common/lhttp/client.go
+++ b/common/lhttp/client.go
@@ -91,13 +91,13 @@ func NewRequest(ctx context.Context, c *http.Client, rFn retry.Factory, rgen Req
switch {
case status == 408, status == 429, status >= 500:
// The HTTP status code means the request should be retried.
- err = errors.Reason("http request failed: %(text)s (HTTP %(code)d)").
- D("text", http.StatusText(status)).D("code", status).Tag(transient.Tag).Err()
+ err = errors.Reason("http request failed: %s (HTTP %d)", http.StatusText(status), status).
+ Tag(transient.Tag).Err()
case status == 404 && strings.HasPrefix(req.URL.Path, "/_ah/api/"):
// Endpoints occasionally return 404 on valid requests!
logging.Infof(ctx, "lhttp.Do() got a Cloud Endpoints 404: %#v", resp.Header)
- err = errors.Reason("http request failed (endpoints): %(text)s (HTTP %(code)d)").
- D("text", http.StatusText(status)).D("code", status).Tag(transient.Tag).Err()
+ err = errors.Reason("http request failed (endpoints): %s (HTTP %d)", http.StatusText(status), status).
+ Tag(transient.Tag).Err()
case status >= 400:
// Any other failure code is a hard failure.
err = fmt.Errorf("http request failed: %s (HTTP %d)", http.StatusText(status), status)
@@ -158,8 +158,7 @@ func NewRequestJSON(ctx context.Context, c *http.Client, rFn retry.Factory, url,
}
if err := json.NewDecoder(resp.Body).Decode(out); err != nil {
// Retriable.
- return errors.Annotate(err).Reason("bad response %(url)s").
- D("url", url).Tag(transient.Tag).Err()
+ return errors.Annotate(err, "bad response %s", url).Tag(transient.Tag).Err()
}
return nil
}, nil), nil
« no previous file with comments | « common/errors/walk_test.go ('k') | common/runtime/profiling/profiler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698