summaryrefslogtreecommitdiffstats
path: root/common/herrors
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-03 09:57:14 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-03 09:57:14 +0200
commitd70c485707edfd445bcfc0e84181bc15eb146e76 (patch)
treeffc5421ae0e102388511054e01d220340f10b2b4 /common/herrors
parent9ff17c332405da5830cef9b3711706b1fc9a7444 (diff)
Make sure module config loading errors have file positioning info
Fixes #8845
Diffstat (limited to 'common/herrors')
-rw-r--r--common/herrors/error_locator.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/common/herrors/error_locator.go b/common/herrors/error_locator.go
index 118ab851c..2c0d215b1 100644
--- a/common/herrors/error_locator.go
+++ b/common/herrors/error_locator.go
@@ -100,6 +100,17 @@ func WithFileContextForFile(e error, realFilename, filename string, fs afero.Fs,
return WithFileContext(e, realFilename, f, matcher)
}
+// WithFileContextForFileDefault tries to add file context using the default line matcher.
+func WithFileContextForFileDefault(err error, filename string, fs afero.Fs) error {
+ err, _ = WithFileContextForFile(
+ err,
+ filename,
+ filename,
+ fs,
+ SimpleLineMatcher)
+ return err
+}
+
// WithFileContextForFile will try to add a file context with lines matching the given matcher.
// If no match could be found, the original error is returned with false as the second return value.
func WithFileContext(e error, realFilename string, r io.Reader, matcher LineMatcherFn) (error, bool) {