-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
84 lines (66 loc) · 1.88 KB
/
errors.go
File metadata and controls
84 lines (66 loc) · 1.88 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package sfstypes
import (
"errors"
"fmt"
)
var (
ErrKeyEmpty = errors.New("key is empty")
ErrDataNull = errors.New("input data is null")
ErrDecodingBool = errors.New("error decoding bool")
)
type ErrDecodingUnsupportedType struct {
sfsType sfsDataType
Len int
Cap int
}
func (err *ErrDecodingUnsupportedType) Error() string {
return fmt.Sprintf("can't decode type %s: len: %d cap: %d", sfsTypeToString(err.sfsType), err.Len, err.Cap)
}
type ErrInsufficientByteData struct {
sfsType sfsDataType
size int
}
func (err *ErrInsufficientByteData) Error() string {
return fmt.Sprintf("can't decode an %s, byte data is insufficient: size: %d", sfsTypeToString(err.sfsType), err.size)
}
type ErrUnsupportedType struct {
value interface{}
}
func (err *ErrUnsupportedType) Error() string {
return fmt.Sprintf("value %v, is of unsupported type %t", err.value, err.value)
}
type ErrWrongType struct {
actualType sfsDataType
wantedType sfsDataType
}
func (err *ErrWrongType) Error() string {
return fmt.Sprintf("found %s but expected type %s", sfsTypeToString(err.actualType), sfsTypeToString(err.wantedType))
}
type ErrKeyNotFound struct {
key string
}
func (err *ErrKeyNotFound) Error() string {
return fmt.Sprintf("key \"%s\" not found", err.key)
}
type ErrInvalidKeySize struct {
key string
length int
}
func (err *ErrInvalidKeySize) Error() string {
return fmt.Sprintf("invalid length of key \"%s\" (%d) (key must be >0 and <256)", err.key, err.length)
}
type ErrIndexNotInRange struct {
index int
}
func (err *ErrIndexNotInRange) Error() string {
return fmt.Sprintf("index %d not in range", err.index)
}
type ErrReadingData struct {
TypeToRead string
Len int
Cap int
IoErr error
}
func (err *ErrReadingData) Error() string {
return fmt.Sprintf("error while reading %s: len: %d cap: %d, ioError: %s", err.TypeToRead, err.Len, err.Cap, err.IoErr)
}