...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package protobuf
16
17 import (
18 "fmt"
19 "strings"
20
21 "cuelang.org/go/cue/token"
22 )
23
24
25 type protobufError struct {
26 path []string
27 pos token.Pos
28 err error
29 }
30
31 func (e *protobufError) Position() token.Pos {
32 return e.pos
33 }
34
35 func (e *protobufError) InputPositions() []token.Pos {
36 return nil
37 }
38
39 func (e *protobufError) Error() string {
40 if e.path == nil {
41 return fmt.Sprintf("protobuf: %s: %v", e.pos, e.err)
42 }
43 path := strings.Join(e.path, ".")
44 return fmt.Sprintf("protobuf: %s:%s: %v", e.pos, path, e.err)
45 }
46
47 func (e *protobufError) Path() []string {
48 return e.path
49 }
50
51 func (e *protobufError) Msg() (format string, args []interface{}) {
52 return "error parsing protobuf: %v", []interface{}{e.err}
53 }
54
View as plain text