Skip to content

Commit

Permalink
Merge pull request #27 from spekary/Better_error
Browse files Browse the repository at this point in the history
Improving error message
  • Loading branch information
spekary authored Feb 10, 2022
2 parents 41f8390 + 6d6c301 commit ac3ee2d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/got/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,17 @@ func (t tokenItem) formatError() (s string) {
if t.typ == itemError {
s = "*** Error: " + t.val + "\n"
for _, c := range t.callStack {
s += " from " + c.formatErrorLine() + "\n"
s += " " + c.formatErrorLine() + "\n"
}
}
return
}

func (r locationRef) formatErrorLine() (s string) {
s += fmt.Sprintf("line: %d, offset: %d ", r.lineNum+1, r.offset)
if r.blockName != "" {
s += "of block: " + r.blockName
s += fmt.Sprintf("Block %s:%d:%d", r.blockName, r.lineNum+1, r.offset)
} else {
s += "of file: " + r.fileName
s += fmt.Sprintf("%s:%d:%d", r.fileName, r.lineNum+1, r.offset)
}
return
}

0 comments on commit ac3ee2d

Please sign in to comment.