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

Unified Diff: common/config/validation/validation.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: copyright 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: common/config/validation/validation.go
diff --git a/common/config/validation/validation.go b/common/config/validation/validation.go
index c5e8d433684eb56edcbd653f4e98ae479414af40..b7807211c2c01c1945899b95dd4c642fd9fb269c 100644
--- a/common/config/validation/validation.go
+++ b/common/config/validation/validation.go
@@ -44,6 +44,9 @@ type Context struct {
element []string // logical path of a sub-element we validate, see Enter
}
+var fileTag = errors.NewTagger("holds the file name for tests")
+var element0Tag = errors.NewTagger("holds the first element for tests")
+
// Error records a validation error.
func (v *Context) Error(msg string, args ...interface{}) {
ctx := ""
@@ -52,7 +55,9 @@ func (v *Context) Error(msg string, args ...interface{}) {
} else {
ctx = "in <unspecified file>"
}
+ tags := []errors.TagValue{fileTag.With(v.file)}
if len(v.element) != 0 {
+ tags = append(tags, element0Tag.With(v.element[0]))
ctx += " (" + strings.Join(v.element, " / ") + ")"
}
@@ -66,9 +71,7 @@ func (v *Context) Error(msg string, args ...interface{}) {
}
// Make the file and the logical path also usable through error inspection.
- err := errors.Reason(fmt.Sprintf(msg, args...)).
- D("file", v.file).
- D("element", append([]string{}, v.element...)).Err()
+ err := errors.Reason(fmt.Sprintf(msg, args...)).Tag(tags...).Err()
v.errors = append(v.errors, err)
}

Powered by Google App Engine
This is Rietveld 408576698