-
Notifications
You must be signed in to change notification settings - Fork 179
/
errors.go
92 lines (73 loc) · 2.1 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
package state
import (
"errors"
"fmt"
)
// InvalidExtensionError is an error for invalid extension of the state
type InvalidExtensionError struct {
err error
}
func NewInvalidExtensionError(msg string) error {
return NewInvalidExtensionErrorf(msg)
}
func NewInvalidExtensionErrorf(msg string, args ...interface{}) error {
return InvalidExtensionError{
err: fmt.Errorf(msg, args...),
}
}
func (e InvalidExtensionError) Unwrap() error {
return e.err
}
func (e InvalidExtensionError) Error() string {
return e.err.Error()
}
// IsInvalidExtensionError returns whether the given error is an InvalidExtensionError error
func IsInvalidExtensionError(err error) bool {
return errors.As(err, &InvalidExtensionError{})
}
// OutdatedExtensionError is an error for the extension of the state being outdated.
// Being outdated doesn't mean it's invalid or not.
// Knowing whether an outdated extension is an invalid extension or not would
// take more state queries.
type OutdatedExtensionError struct {
err error
}
func NewOutdatedExtensionError(msg string) error {
return NewOutdatedExtensionErrorf(msg)
}
func NewOutdatedExtensionErrorf(msg string, args ...interface{}) error {
return OutdatedExtensionError{
err: fmt.Errorf(msg, args...),
}
}
func (e OutdatedExtensionError) Unwrap() error {
return e.err
}
func (e OutdatedExtensionError) Error() string {
return e.err.Error()
}
func IsOutdatedExtensionError(err error) bool {
return errors.As(err, &OutdatedExtensionError{})
}
// NoValidChildBlockError is a sentinel error when the case where a certain block has
// no valid child.
type NoValidChildBlockError struct {
err error
}
func NewNoValidChildBlockError(msg string) error {
return NoValidChildBlockError{
err: fmt.Errorf(msg),
}
}
func NewNoValidChildBlockErrorf(msg string, args ...interface{}) error {
return NewNoValidChildBlockError(fmt.Sprintf(msg, args...))
}
func (e NoValidChildBlockError) Unwrap() error {
return e.err
}
func (e NoValidChildBlockError) Error() string {
return e.err.Error()
}
func IsNoValidChildBlockError(err error) bool {
return errors.As(err, &NoValidChildBlockError{})
}