-
Notifications
You must be signed in to change notification settings - Fork 141
/
errors.go
54 lines (44 loc) · 1.26 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
package certificate
import (
"fmt"
"reflect"
)
// BasicCheckError is returned when the basic check on the certificate fails.
type BasicCheckError struct {
Reason string
}
func (e BasicCheckError) Error() string {
return e.Reason
}
// UnexpectedHeightError is returned when the height of the certificate
// is invalid.
type UnexpectedHeightError struct {
Expected uint32
Got uint32
}
func (e UnexpectedHeightError) Error() string {
return fmt.Sprintf("certificate height is invalid (expected %v got %v)",
e.Expected, e.Got)
}
// UnexpectedCommittersError is returned when the list of committers
// does not match the expectations.
type UnexpectedCommittersError struct {
Committers []int32
}
func (e UnexpectedCommittersError) Error() string {
return fmt.Sprintf("certificate has an unexpected committers: %v",
e.Committers)
}
func (e UnexpectedCommittersError) Is(target error) bool {
return reflect.DeepEqual(e, target)
}
// InsufficientPowerError is returned when the accumulated power does not meet
// the required threshold.
type InsufficientPowerError struct {
SignedPower int64
RequiredPower int64
}
func (e InsufficientPowerError) Error() string {
return fmt.Sprintf("accumulated power is %v, should be at least %v",
e.SignedPower, e.RequiredPower)
}