From d70c485707edfd445bcfc0e84181bc15eb146e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 3 Aug 2021 09:57:14 +0200 Subject: Make sure module config loading errors have file positioning info Fixes #8845 --- common/herrors/error_locator.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common/herrors') 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) { -- cgit v1.2.3