File: error.go

package info (click to toggle)
golang-github-influxdata-toml 0.0~git20160905.0.ad49a5c-1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 256 kB
  • ctags: 349
  • sloc: makefile: 14
file content (31 lines) | stat: -rw-r--r-- 609 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package toml

import (
	"fmt"
	"reflect"
)

func (e *parseError) Line() int {
	tokens := e.p.tokenTree.Error()
	positions := make([]int, len(tokens)*2)
	p := 0
	for _, token := range tokens {
		positions[p], p = int(token.begin), p+1
		positions[p], p = int(token.end), p+1
	}
	for _, t := range translatePositions(e.p.Buffer, positions) {
		if e.p.line < t.line {
			e.p.line = t.line
		}
	}
	return e.p.line
}

type errorOutOfRange struct {
	kind reflect.Kind
	v    interface{}
}

func (err *errorOutOfRange) Error() string {
	return fmt.Sprintf("value %d is out of range for `%v` type", err.v, err.kind)
}