forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
96 lines (76 loc) · 1.97 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
package mempool
import (
"errors"
"fmt"
)
// ErrTxNotFound is returned to the client if tx is not found in mempool.
var ErrTxNotFound = errors.New("transaction not found in mempool")
// ErrTxInCache is returned to the client if we saw tx earlier.
var ErrTxInCache = errors.New("tx already exists in cache")
// ErrTxTooLarge defines an error when a transaction is too big to be sent in a
// message to other peers.
type ErrTxTooLarge struct {
Max int
Actual int
}
func (e ErrTxTooLarge) Error() string {
return fmt.Sprintf("Tx too large. Max size is %d, but got %d", e.Max, e.Actual)
}
// ErrMempoolIsFull defines an error where CometBFT and the application cannot
// handle that much load.
type ErrMempoolIsFull struct {
NumTxs int
MaxTxs int
TxsBytes int64
MaxTxsBytes int64
}
func (e ErrMempoolIsFull) Error() string {
return fmt.Sprintf(
"mempool is full: number of txs %d (max: %d), total txs bytes %d (max: %d)",
e.NumTxs,
e.MaxTxs,
e.TxsBytes,
e.MaxTxsBytes,
)
}
// ErrPreCheck defines an error where a transaction fails a pre-check.
type ErrPreCheck struct {
Err error
}
func (e ErrPreCheck) Error() string {
return fmt.Sprintf("tx pre check: %v", e.Err)
}
func (e ErrPreCheck) Unwrap() error {
return e.Err
}
// IsPreCheckError returns true if err is due to pre check failure.
func IsPreCheckError(err error) bool {
return errors.As(err, &ErrPreCheck{})
}
type ErrCheckTxAsync struct {
Err error
}
func (e ErrCheckTxAsync) Error() string {
return fmt.Sprintf("check tx async: %v", e.Err)
}
func (e ErrCheckTxAsync) Unwrap() error {
return e.Err
}
type ErrAppConnMempool struct {
Err error
}
func (e ErrAppConnMempool) Error() string {
return fmt.Sprintf("appConn mempool: %v", e.Err)
}
func (e ErrAppConnMempool) Unwrap() error {
return e.Err
}
type ErrFlushAppConn struct {
Err error
}
func (e ErrFlushAppConn) Error() string {
return fmt.Sprintf("flush appConn mempool: %v", e.Err)
}
func (e ErrFlushAppConn) Unwrap() error {
return e.Err
}