-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy patherrors.go
More file actions
132 lines (103 loc) · 4 KB
/
errors.go
File metadata and controls
132 lines (103 loc) · 4 KB
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
package access
import (
"errors"
"fmt"
"github.com/onflow/cadence"
"github.com/onflow/flow-go/model/flow"
)
// ErrUnknownReferenceBlock indicates that a transaction references an unknown block.
var ErrUnknownReferenceBlock = errors.New("unknown reference block")
// IndexReporterNotInitialized is returned when indexReporter is nil because
// execution data syncing and indexing is disabled
var IndexReporterNotInitialized = errors.New("index reported not initialized")
// IncompleteTransactionError indicates that a transaction is missing one or more required fields.
type IncompleteTransactionError struct {
MissingFields []string
}
func (e IncompleteTransactionError) Error() string {
return fmt.Sprintf("transaction is missing required fields: %s", e.MissingFields)
}
// ExpiredTransactionError indicates that a transaction has expired.
type ExpiredTransactionError struct {
RefHeight, FinalHeight uint64
}
func (e ExpiredTransactionError) Error() string {
return fmt.Sprintf("transaction is expired: ref_height=%d final_height=%d", e.RefHeight, e.FinalHeight)
}
// InvalidScriptError indicates that a transaction contains an invalid Cadence script.
type InvalidScriptError struct {
ParserErr error
}
func (e InvalidScriptError) Error() string {
return fmt.Sprintf("failed to parse transaction Cadence script: %s", e.ParserErr)
}
func (e InvalidScriptError) Unwrap() error {
return e.ParserErr
}
// InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.
type InvalidGasLimitError struct {
Maximum uint64
Actual uint64
}
func (e InvalidGasLimitError) Error() string {
return fmt.Sprintf("transaction gas limit (%d) is not in the acceptable range (min: 1, max: %d)", e.Actual, e.Maximum)
}
// InvalidAddressError indicates that a transaction references an invalid flow Address
// in either the Authorizers or Payer field.
type InvalidAddressError struct {
Address flow.Address
}
func (e InvalidAddressError) Error() string {
return fmt.Sprintf("invalid address: %s", e.Address)
}
// DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)
type DuplicatedSignatureError struct {
Address flow.Address
KeyIndex uint32
}
func (e DuplicatedSignatureError) Error() string {
return fmt.Sprintf("duplicated signature for key (address: %s, index: %d)", e.Address.String(), e.KeyIndex)
}
// InvalidSignatureError indicates that a transaction contains a signature
// with a wrong format.
type InvalidSignatureError struct {
Signature flow.TransactionSignature
}
func (e InvalidSignatureError) Error() string {
return fmt.Sprintf("invalid signature: %s", e.Signature)
}
// InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.
type InvalidTxByteSizeError struct {
Maximum uint64
Actual uint64
}
func (e InvalidTxByteSizeError) Error() string {
return fmt.Sprintf("transaction byte size (%d) exceeds the maximum byte size allowed for a transaction (%d)", e.Actual, e.Maximum)
}
type InvalidTxRateLimitedError struct {
Payer flow.Address
}
func (e InvalidTxRateLimitedError) Error() string {
return fmt.Sprintf("transaction rate limited for payer (%s)", e.Payer)
}
type InsufficientBalanceError struct {
Payer flow.Address
RequiredBalance cadence.UFix64
}
func (e InsufficientBalanceError) Error() string {
return fmt.Sprintf("transaction payer (%s) has insufficient balance to pay transaction fee. "+
"Required balance: (%s). ", e.Payer, e.RequiredBalance.String())
}
func IsInsufficientBalanceError(err error) bool {
var balanceError InsufficientBalanceError
return errors.As(err, &balanceError)
}
// IndexedHeightFarBehindError indicates that a node is far behind on indexing.
type IndexedHeightFarBehindError struct {
SealedHeight uint64
IndexedHeight uint64
}
func (e IndexedHeightFarBehindError) Error() string {
return fmt.Sprintf("the difference between the latest sealed height (%d) and indexed height (%d) exceeds the maximum gap allowed",
e.SealedHeight, e.IndexedHeight)
}