aboutsummaryrefslogtreecommitdiff
path: root/error/error.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-08-22 19:15:03 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-08-22 19:15:03 +0900
commit02674d7264aea363a8f7b7839ab77ce64ba720db (patch)
treea849d566004b7d1e711fa4c667a54a5eab322c78 /error/error.go
parentSupport %left and %right to specify precedences and associativities (diff)
downloadurubu-02674d7264aea363a8f7b7839ab77ce64ba720db.tar.gz
urubu-02674d7264aea363a8f7b7839ab77ce64ba720db.tar.xz
Add a column number to an error message
Diffstat (limited to 'error/error.go')
-rw-r--r--error/error.go5
1 files changed, 3 insertions, 2 deletions
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 != "" {