-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.go
70 lines (55 loc) · 1.47 KB
/
errors.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package kdlgo
import (
"errors"
"strconv"
)
type KDLErrorType string
const (
KDLEmptyArray = "Array is empty"
KDLDifferentKey = "All keys of KDLObject to convert to document should be the same"
KDLInvalidKeyChar = "Invalid character for key"
KDLInvalidNumValue = "Invalid numeric value"
KDLInvalidSyntax = "Invalid syntax"
KDLInvalidType = "Invalid KDLType"
KDLUnexpectedEOF = "Unexpected end of file"
// These should be caught and handled internally
kdlKeyOnly = "Internal only: Key only"
kdlEndOfObj = "Internal only: End of KDLObject"
kdlNothingLeft = "Internal only: Nothing else left to parse"
)
func wrapError(kdlr *kdlReader, err error) error {
return errors.New(
err.Error() + "\nOn line " + strconv.Itoa(kdlr.line) +
" column " + strconv.Itoa(kdlr.pos),
)
}
func differentKeysErr() error {
return errors.New(KDLDifferentKey)
}
func emptyArrayErr() error {
return errors.New(KDLEmptyArray)
}
func invalidKeyCharErr() error {
return errors.New(KDLInvalidKeyChar)
}
func invalidNumValueErr() error {
return errors.New(KDLInvalidNumValue)
}
func invalidSyntaxErr() error {
return errors.New(KDLInvalidSyntax)
}
func invalidTypeErr() error {
return errors.New(KDLInvalidType)
}
func keyOnlyErr() error {
return errors.New(kdlKeyOnly)
}
func endOfObjErr() error {
return errors.New(kdlEndOfObj)
}
func nothingLeftErr() error {
return errors.New(kdlNothingLeft)
}
func unexpectedEOFErr() error {
return errors.New(KDLUnexpectedEOF)
}