...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package compile
16
17 import (
18 "strings"
19
20 "cuelang.org/go/cue/ast"
21 "cuelang.org/go/cue/errors"
22 "cuelang.org/go/cue/token"
23 )
24
25 var _ errors.Error = &compilerError{}
26
27 type compilerError struct {
28 n ast.Node
29 path []string
30 errors.Message
31 }
32
33 func (e *compilerError) Position() token.Pos { return e.n.Pos() }
34 func (e *compilerError) InputPositions() []token.Pos { return nil }
35 func (e *compilerError) Path() []string { return e.path }
36 func (e *compilerError) Error() string {
37 pos := e.n.Pos()
38
39 if pos.IsValid() {
40
41
42 return pos.String() + ": " + e.Message.Error()
43 }
44 if len(e.path) == 0 {
45 return e.Message.Error()
46 }
47 return strings.Join(e.path, ".") + ": " + e.Message.Error()
48 }
49
View as plain text