summaryrefslogtreecommitdiffstats
path: root/common/herrors/error_locator.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/herrors/error_locator.go')
-rw-r--r--common/herrors/error_locator.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/herrors/error_locator.go b/common/herrors/error_locator.go
index c7e2d2f06..7624bab98 100644
--- a/common/herrors/error_locator.go
+++ b/common/herrors/error_locator.go
@@ -61,6 +61,16 @@ var OffsetMatcher = func(m LineMatcher) int {
return -1
}
+// ContainsMatcher is a line matcher that matches by line content.
+func ContainsMatcher(text string) func(m LineMatcher) int {
+ return func(m LineMatcher) int {
+ if idx := strings.Index(m.Line, text); idx != -1 {
+ return idx + 1
+ }
+ return -1
+ }
+}
+
// ErrorContext contains contextual information about an error. This will
// typically be the lines surrounding some problem in a file.
type ErrorContext struct {