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

Unified Diff: luci_config/server/cfgclient/backend/format/format.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
Index: luci_config/server/cfgclient/backend/format/format.go
diff --git a/luci_config/server/cfgclient/backend/format/format.go b/luci_config/server/cfgclient/backend/format/format.go
index a77809da44dc3ea299729afffa09f127ad84c8e9..31da089bd35d16845a353383e3b6f450630034e7 100644
--- a/luci_config/server/cfgclient/backend/format/format.go
+++ b/luci_config/server/cfgclient/backend/format/format.go
@@ -37,14 +37,12 @@ func (b *Backend) Get(c context.Context, configSet, path string, p backend.Param
if !p.FormatSpec.Unformatted() {
formatter, err := getFormatter(p.FormatSpec.Formatter)
if err != nil {
- return nil, errors.Annotate(err).Reason("failed to get formatter for %(format)q").
- D("format", p.FormatSpec).Err()
+ return nil, errors.Annotate(err, "failed to get formatter for %q", p.FormatSpec).Err()
}
if err := b.formatItem(item, formatter, p.FormatSpec); err != nil {
- return nil, errors.Annotate(err).Reason("failed to format item to %(format)q, data %(data)q").
- D("format", p.FormatSpec.Formatter).
- D("data", p.FormatSpec.Data).Err()
+ return nil, errors.Annotate(err, "failed to format item to %q, data %q",
+ p.FormatSpec.Formatter, p.FormatSpec.Data).Err()
}
}
return item, nil
@@ -62,9 +60,8 @@ func (b *Backend) GetAll(c context.Context, t backend.GetAllTarget, path string,
if !p.FormatSpec.Unformatted() {
formatter, err := getFormatter(p.FormatSpec.Formatter)
if err != nil {
- return nil, errors.Annotate(err).Reason("failed to get formatter for %(format)q, data %(data)q").
- D("format", p.FormatSpec.Formatter).
- D("data", p.FormatSpec.Data).Err()
+ return nil, errors.Annotate(err, "failed to get formatter for %q, data %q",
+ p.FormatSpec.Formatter, p.FormatSpec.Data).Err()
}
lme := errors.NewLazyMultiError(len(items))
@@ -75,9 +72,8 @@ func (b *Backend) GetAll(c context.Context, t backend.GetAllTarget, path string,
}
if err := lme.Get(); err != nil {
- return nil, errors.Annotate(err).Reason("failed to format items to %(format)q, data %(data)q").
- D("format", p.FormatSpec.Formatter).
- D("data", p.FormatSpec.Data).Err()
+ return nil, errors.Annotate(err, "failed to format items to %q, data %q",
+ p.FormatSpec.Formatter, p.FormatSpec.Data).Err()
}
}
return items, nil
@@ -92,7 +88,7 @@ func (b *Backend) formatItem(it *backend.Item, formatter Formatter, fs backend.F
// Item is not formatted, so format it.
content, err := formatter.FormatItem(it.Content, fs.Data)
if err != nil {
- return errors.Annotate(err).Reason("failed to format item").Err()
+ return errors.Annotate(err, "failed to format item").Err()
}
it.Content = content
it.FormatSpec = fs
« no previous file with comments | « luci_config/server/cfgclient/backend/client/client.go ('k') | luci_config/server/cfgclient/backend/format/formatters.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698