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

Unified Diff: deploytool/cmd/luci_deploy/util.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 | « deploytool/cmd/luci_deploy/tools.go ('k') | deploytool/cmd/luci_deploy/version.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: deploytool/cmd/luci_deploy/util.go
diff --git a/deploytool/cmd/luci_deploy/util.go b/deploytool/cmd/luci_deploy/util.go
index 1db382be7fa716c7e90940d7f691429ff557bcd5..468875f93a720bd2055d36602414df6537987335 100644
--- a/deploytool/cmd/luci_deploy/util.go
+++ b/deploytool/cmd/luci_deploy/util.go
@@ -22,8 +22,7 @@ func unmarshalTextProtobuf(path string, msg proto.Message) error {
switch {
case err == nil:
if err := proto.UnmarshalText(string(data), msg); err != nil {
- return errors.Annotate(err).Reason("failed to unmarshal %(type)T from [%(path)s]").
- D("type", msg).D("path", path).Err()
+ return errors.Annotate(err, "failed to unmarshal %T from [%s]", msg, path).Err()
}
return nil
@@ -32,7 +31,7 @@ func unmarshalTextProtobuf(path string, msg proto.Message) error {
return err
default:
- return errors.Annotate(err).Reason("failed to read data from [%(path)s]").D("path", path).Err()
+ return errors.Annotate(err, "failed to read data from [%s]", path).Err()
}
}
@@ -44,10 +43,10 @@ func unmarshalTextProtobufDir(base string, fis []os.FileInfo, msg proto.Message,
}
if err := unmarshalTextProtobuf(filepath.Join(base, name), msg); err != nil {
- return errors.Annotate(err).Reason("failed to unmarshal file [%(name)s]").D("name", name).Err()
+ return errors.Annotate(err, "failed to unmarshal file [%s]", name).Err()
}
if err := cb(name); err != nil {
- return errors.Annotate(err).Reason("failed to process file [%(name)s]").D("name", name).Err()
+ return errors.Annotate(err, "failed to process file [%s]", name).Err()
}
}
return nil
@@ -56,7 +55,7 @@ func unmarshalTextProtobufDir(base string, fis []os.FileInfo, msg proto.Message,
func logError(c context.Context, err error, f string, args ...interface{}) {
log.WithError(err).Errorf(c, f, args...)
if log.IsLogging(c, log.Debug) {
- log.Debugf(c, "Error stack:\n%s", strings.Join(errors.RenderStack(err).ToLines(), "\n"))
+ log.Debugf(c, "Error stack:\n%s", strings.Join(errors.RenderStack(err), "\n"))
}
}
« no previous file with comments | « deploytool/cmd/luci_deploy/tools.go ('k') | deploytool/cmd/luci_deploy/version.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698