diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-08-03 09:57:14 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-08-03 09:57:14 +0200 |
commit | d70c485707edfd445bcfc0e84181bc15eb146e76 (patch) | |
tree | ffc5421ae0e102388511054e01d220340f10b2b4 /common | |
parent | 9ff17c332405da5830cef9b3711706b1fc9a7444 (diff) |
Make sure module config loading errors have file positioning info
Fixes #8845
Diffstat (limited to 'common')
-rw-r--r-- | common/herrors/error_locator.go | 11 |
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) { |