MCPcopy Create free account
hub / github.com/brimdata/super / Error

Method Error

compiler/srcfiles/error.go:43–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41}
42
43func (e *Error) Error() string {
44 if e.list == nil || e.Pos < 0 {
45 return e.Msg
46 }
47 file := e.list.FileOf(e.Pos)
48 start := file.Position(e.Pos)
49 end := file.Position(e.End)
50 var b strings.Builder
51 b.WriteString(e.Msg)
52 if file.Name != "" {
53 fmt.Fprintf(&b, " in %s", file.Name)
54 }
55 line := file.LineOfPos(e.list.Text, e.Pos)
56 fmt.Fprintf(&b, " at line %d, column %d:\n%s\n", start.Line, start.Column, line)
57 if end.IsValid() {
58 formatSpanError(&b, line, start, end)
59 } else {
60 formatPointError(&b, start)
61 }
62 return b.String()
63}
64
65func formatSpanError(b *strings.Builder, line string, start, end Position) {
66 b.WriteString(strings.Repeat(" ", start.Column-1))

Callers 1

ErrorMethod · 0.45

Calls 7

formatSpanErrorFunction · 0.85
formatPointErrorFunction · 0.85
FileOfMethod · 0.80
LineOfPosMethod · 0.80
IsValidMethod · 0.80
StringMethod · 0.65
PositionMethod · 0.45

Tested by

no test coverage detected