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

Unified Diff: appengine/datastorecache/manager.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 | « no previous file | appengine/gaeauth/server/oauth.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/datastorecache/manager.go
diff --git a/appengine/datastorecache/manager.go b/appengine/datastorecache/manager.go
index da801bd328659a6d7072901adfd43a90e83e4d2b..4beac6b0fbd64db9ba24f3576e32190bd3584925 100644
--- a/appengine/datastorecache/manager.go
+++ b/appengine/datastorecache/manager.go
@@ -5,7 +5,6 @@
package datastorecache
import (
- "bytes"
"fmt"
"net/http"
"strings"
@@ -41,17 +40,15 @@ func errHTTPHandler(fn func(c context.Context, req *http.Request, params httprou
// maximum log message size with a full stack.
stk := errors.RenderStack(err)
log.WithError(err).Errorf(ctx.Context, "Handler returned error.")
- for _, line := range stk.ToLines() {
+ for _, line := range stk {
log.Errorf(ctx.Context, ">> %s", line)
}
dumpErr := func() error {
- var buf bytes.Buffer
- if _, err := stk.DumpTo(&buf); err != nil {
- return err
- }
- if _, err := buf.WriteTo(ctx.Writer); err != nil {
- return err
+ for _, line := range stk {
+ if _, err := ctx.Writer.Write([]byte(line + "\n")); err != nil {
+ return err
+ }
}
return nil
}()
@@ -148,12 +145,12 @@ func (ms *managerShard) run(c context.Context) error {
}()
if err := ms.runLocked(c); err != nil {
- return errors.Annotate(err).Err()
+ return errors.Annotate(err, "running maintenance loop").Err()
}
// If we observed errors during processing, note this.
if ms.errors > 0 {
- return errors.Reason("%(count)d error(s) encountered during processing").D("count", ms.errors).Err()
+ return errors.Reason("%d error(s) encountered during processing", ms.errors).Err()
}
return nil
})
@@ -330,7 +327,7 @@ func (ms *managerShard) runLocked(c context.Context) error {
return nil
})
if err != nil {
- return errors.Annotate(err).Reason("failed to run entry query").Err()
+ return errors.Annotate(err, "failed to run entry query").Err()
}
// Flush any outstanding entries (ignore error, will always be nil).
« no previous file with comments | « no previous file | appengine/gaeauth/server/oauth.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698