-
Notifications
You must be signed in to change notification settings - Fork 175
/
errors.go
154 lines (118 loc) · 4.96 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package signature
import (
"errors"
"fmt"
)
var (
ErrInvalidSignatureFormat = errors.New("signature's binary format is invalid")
ErrInsufficientShares = errors.New("insufficient threshold signature shares")
// ErrIncompatibleBitVectorLength indicates that the bit vector's length is different than
// the expected length, based on the supplied node list.
ErrIncompatibleBitVectorLength = errors.New("bit vector has incompatible length")
// ErrIllegallyPaddedBitVector indicates that the index vector was padded with unexpected bit values.
ErrIllegallyPaddedBitVector = errors.New("index vector padded with unexpected bit values")
// ErrInvalidChecksum indicates that the index vector's checksum is invalid
ErrInvalidChecksum = errors.New("index vector's checksum is invalid")
)
/* ********************* InvalidSignatureIncludedError ********************* */
// InvalidSignatureIncludedError indicates that some signatures, included via TrustedAdd, are invalid
type InvalidSignatureIncludedError struct {
err error
}
func NewInvalidSignatureIncludedErrorf(msg string, args ...interface{}) error {
return InvalidSignatureIncludedError{
err: fmt.Errorf(msg, args...),
}
}
func (e InvalidSignatureIncludedError) Error() string { return e.err.Error() }
func (e InvalidSignatureIncludedError) Unwrap() error { return e.err }
// IsInvalidSignatureIncludedError returns whether err is an InvalidSignatureIncludedError
func IsInvalidSignatureIncludedError(err error) bool {
var e InvalidSignatureIncludedError
return errors.As(err, &e)
}
/* ************************* InvalidSignerIdxError ************************* */
// InvalidSignerIdxError indicates that the signer index is invalid
type InvalidSignerIdxError struct {
err error
}
func NewInvalidSignerIdxErrorf(msg string, args ...interface{}) error {
return InvalidSignerIdxError{
err: fmt.Errorf(msg, args...),
}
}
func (e InvalidSignerIdxError) Error() string { return e.err.Error() }
func (e InvalidSignerIdxError) Unwrap() error { return e.err }
// IsInvalidSignerIdxError returns whether err is an InvalidSignerIdxError
func IsInvalidSignerIdxError(err error) bool {
var e InvalidSignerIdxError
return errors.As(err, &e)
}
/* ************************ DuplicatedSignerIdxError *********************** */
// DuplicatedSignerIdxError indicates that a signature from the respective signer index was already added
type DuplicatedSignerIdxError struct {
err error
}
func NewDuplicatedSignerIdxErrorf(msg string, args ...interface{}) error {
return DuplicatedSignerIdxError{
err: fmt.Errorf(msg, args...),
}
}
func (e DuplicatedSignerIdxError) Error() string { return e.err.Error() }
func (e DuplicatedSignerIdxError) Unwrap() error { return e.err }
// IsDuplicatedSignerIdxError returns whether err is an DuplicatedSignerIdxError
func IsDuplicatedSignerIdxError(err error) bool {
var e DuplicatedSignerIdxError
return errors.As(err, &e)
}
/* ********************** InsufficientSignaturesError ********************** */
// InsufficientSignaturesError indicates that not enough signatures have been stored to complete the operation.
type InsufficientSignaturesError struct {
err error
}
func NewInsufficientSignaturesErrorf(msg string, args ...interface{}) error {
return InsufficientSignaturesError{
err: fmt.Errorf(msg, args...),
}
}
func (e InsufficientSignaturesError) Error() string { return e.err.Error() }
func (e InsufficientSignaturesError) Unwrap() error { return e.err }
// IsInsufficientSignaturesError returns whether err is an InsufficientSignaturesError
func IsInsufficientSignaturesError(err error) bool {
var e InsufficientSignaturesError
return errors.As(err, &e)
}
/* ********************** InvalidSignerIndicesError ********************** */
// InvalidSignerIndicesError indicates that a bit vector does not encode a valid set of signers
type InvalidSignerIndicesError struct {
err error
}
func NewInvalidSignerIndicesErrorf(msg string, args ...interface{}) error {
return InvalidSignerIndicesError{
err: fmt.Errorf(msg, args...),
}
}
func (e InvalidSignerIndicesError) Error() string { return e.err.Error() }
func (e InvalidSignerIndicesError) Unwrap() error { return e.err }
// IsInvalidSignerIndicesError returns whether err is an InvalidSignerIndicesError
func IsInvalidSignerIndicesError(err error) bool {
var e InvalidSignerIndicesError
return errors.As(err, &e)
}
/* ********************** InvalidSignerIndicesError ********************** */
// InvalidSigTypesError indicates that the given data not encode valid signature types
type InvalidSigTypesError struct {
err error
}
func NewInvalidSigTypesErrorf(msg string, args ...interface{}) error {
return InvalidSigTypesError{
err: fmt.Errorf(msg, args...),
}
}
func (e InvalidSigTypesError) Error() string { return e.err.Error() }
func (e InvalidSigTypesError) Unwrap() error { return e.err }
// IsInvalidSigTypesError returns whether err is an InvalidSigTypesError
func IsInvalidSigTypesError(err error) bool {
var e InvalidSigTypesError
return errors.As(err, &e)
}