From 02674d7264aea363a8f7b7839ab77ce64ba720db Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 22 Aug 2021 19:15:03 +0900 Subject: Add a column number to an error message --- error/error.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'error/error.go') diff --git a/error/error.go b/error/error.go index 1781f2a..0e5d3af 100644 --- a/error/error.go +++ b/error/error.go @@ -39,6 +39,7 @@ type SpecError struct { FilePath string SourceName string Row int + Col int } func (e *SpecError) Error() string { @@ -46,8 +47,8 @@ func (e *SpecError) Error() string { if e.SourceName != "" { fmt.Fprintf(&b, "%v: ", e.SourceName) } - if e.Row != 0 { - fmt.Fprintf(&b, "%v: ", e.Row) + if e.Row != 0 && e.Col != 0 { + fmt.Fprintf(&b, "%v:%v: ", e.Row, e.Col) } fmt.Fprintf(&b, "error: %v", e.Cause) if e.Detail != "" { -- cgit v1.2.3