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) |
} |