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

Unified Diff: cipd/client/cipd/ensure/file.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: all tests passing 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: cipd/client/cipd/ensure/file.go
diff --git a/cipd/client/cipd/ensure/file.go b/cipd/client/cipd/ensure/file.go
index 1328c147e3269524396c834b0b32a3f89bbdd4d6..65775ccb61863e3c14c3de4b9cd3f0a7287ad3d9 100644
--- a/cipd/client/cipd/ensure/file.go
+++ b/cipd/client/cipd/ensure/file.go
@@ -137,7 +137,7 @@ func (f *File) ResolveWith(rslv VersionResolver, templateArgs map[string]string)
if f.ServiceURL != "" {
// double check the url
if _, err := url.Parse(f.ServiceURL); err != nil {
- return nil, errors.Annotate(err).Reason("bad ServiceURL").Err()
+ return nil, errors.Annotate(err, "bad ServiceURL").Err()
}
}
@@ -153,10 +153,7 @@ func (f *File) ResolveWith(rslv VersionResolver, templateArgs map[string]string)
for subdir, pkgs := range f.PackagesBySubdir {
// double-check the subdir
if err := common.ValidateSubdir(subdir); err != nil {
- return nil, errors.Annotate(err).
- Reason("normalizing %(subdir)q").
- D("subdir", subdir).
- Err()
+ return nil, errors.Annotate(err, "normalizing %q", subdir).Err()
}
for _, pkg := range pkgs {
pin, err := pkg.Resolve(rslv, templateArgs)
@@ -164,17 +161,13 @@ func (f *File) ResolveWith(rslv VersionResolver, templateArgs map[string]string)
continue
}
if err != nil {
- return nil, errors.Annotate(err).Reason("resolving package").Err()
+ return nil, errors.Annotate(err, "resolving package").Err()
}
if origLineNo, ok := resolvedPkgDupList[subdir][pin.PackageName]; ok {
return nil, errors.
- Reason("duplicate package in subdir %(subdir)q: %(pkg)q: defined on line %(orig)d and %(new)d").
- D("subdir", subdir).
- D("pkg", pin.PackageName).
- D("orig", origLineNo).
- D("new", pkg.LineNo).
- Err()
+ Reason("duplicate package in subdir %q: %q: defined on line %d and %d",
+ subdir, pin.PackageName, origLineNo, pkg.LineNo).Err()
}
if resolvedPkgDupList[subdir] == nil {
resolvedPkgDupList[subdir] = map[string]int{}

Powered by Google App Engine
This is Rietveld 408576698