-
Notifications
You must be signed in to change notification settings - Fork 178
/
errors.go
62 lines (50 loc) · 1.71 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
package mempool
import (
"errors"
"fmt"
)
// UnknownExecutionResultError indicates that the Execution Result is unknown
type UnknownExecutionResultError struct {
err error
}
func NewUnknownExecutionResultError(msg string) error {
return NewUnknownExecutionResultErrorf(msg)
}
func NewUnknownExecutionResultErrorf(msg string, args ...interface{}) error {
return UnknownExecutionResultError{
err: fmt.Errorf(msg, args...),
}
}
func (e UnknownExecutionResultError) Unwrap() error {
return e.err
}
func (e UnknownExecutionResultError) Error() string {
return e.err.Error()
}
// IsUnknownExecutionResultError returns whether the given error is an UnknownExecutionResultError error
func IsUnknownExecutionResultError(err error) bool {
var unknownExecutionResultError UnknownExecutionResultError
return errors.As(err, &unknownExecutionResultError)
}
// BelowPrunedThresholdError indicates that we are attempting to query or prune a mempool by a
// key (typically block height or block view) which is lower than the lowest retained key threshold.
// In other words, we have already pruned above the specified key value.
type BelowPrunedThresholdError struct {
err error
}
func NewBelowPrunedThresholdErrorf(msg string, args ...interface{}) error {
return BelowPrunedThresholdError{
err: fmt.Errorf(msg, args...),
}
}
func (e BelowPrunedThresholdError) Unwrap() error {
return e.err
}
func (e BelowPrunedThresholdError) Error() string {
return e.err.Error()
}
// IsBelowPrunedThresholdError returns whether the given error is an BelowPrunedThresholdError error
func IsBelowPrunedThresholdError(err error) bool {
var newIsBelowPrunedThresholdError BelowPrunedThresholdError
return errors.As(err, &newIsBelowPrunedThresholdError)
}