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

Unified Diff: buildbucket/client/cmd/buildbucket/client.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor 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
Index: buildbucket/client/cmd/buildbucket/client.go
diff --git a/buildbucket/client/cmd/buildbucket/client.go b/buildbucket/client/cmd/buildbucket/client.go
index 64ca76a963bc8224c26886c87c643a72616d06da..75b7701510e6769271fd54eda2bafe33b9f5ab4c 100644
--- a/buildbucket/client/cmd/buildbucket/client.go
+++ b/buildbucket/client/cmd/buildbucket/client.go
@@ -15,9 +15,9 @@ import (
"golang.org/x/net/context"
- "github.com/luci/luci-go/common/errors"
"github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/common/retry"
+ "github.com/luci/luci-go/common/retry/transient"
"golang.org/x/net/context/ctxhttp"
)
@@ -50,7 +50,7 @@ func (c *client) call(ctx context.Context, method, urlStr string, body interface
err = retry.Retry(
ctx,
- retry.TransientOnly(retry.Default),
+ transient.Only(retry.Default),
func() error {
req := &http.Request{Method: method, URL: u}
if bodyBytes != nil {
@@ -58,14 +58,13 @@ func (c *client) call(ctx context.Context, method, urlStr string, body interface
}
res, err := ctxhttp.Do(ctx, c.HTTP, req)
if err != nil {
- return errors.WrapTransient(err)
+ return transient.Tag.Apply(err)
}
defer res.Body.Close()
if res.StatusCode >= 500 {
bodyBytes, _ := ioutil.ReadAll(res.Body)
- return errors.WrapTransient(fmt.Errorf(
- "status %s: %s", res.Status, bodyBytes))
+ return transient.Tag.Apply(fmt.Errorf("status %s: %s", res.Status, bodyBytes))
}
response, err = ioutil.ReadAll(res.Body)

Powered by Google App Engine
This is Rietveld 408576698