-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
errors.go
169 lines (125 loc) · 6.8 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//Package errors provides a shared set of errors for use in the SDK,
//aliases functionality in the github.com/cosmos/cosmos-sdk/errors module
//that used to be in this package, and provides some helpers for converting
//errors to ABCI response code.
//
//New code should generally import github.com/cosmos/cosmos-sdk/errors directly
//and define a custom set of errors in custom codespace, rather than importing
//this package.
package errors
import (
errorsmod "github.com/cosmos/cosmos-sdk/errors"
)
var (
SuccessABCICode = errorsmod.SuccessABCICode
ABCIInfo = errorsmod.ABCIInfo
Redact = errorsmod.Redact
UndefinedCodespace = errorsmod.UndefinedCodespace
Register = errorsmod.Register
ABCIError = errorsmod.ABCIError
New = errorsmod.New
Wrap = errorsmod.Wrap
Wrapf = errorsmod.Wrapf
Recover = errorsmod.Recover
WithType = errorsmod.WithType
IsOf = errorsmod.IsOf
AssertNil = errorsmod.AssertNil
)
type (
Error = errorsmod.Error
)
// RootCodespace is the codespace for all errors defined in this package
const RootCodespace = "sdk"
var (
// ErrTxDecode is returned if we cannot parse a transaction
ErrTxDecode = Register(RootCodespace, 2, "tx parse error")
// ErrInvalidSequence is used the sequence number (nonce) is incorrect
// for the signature
ErrInvalidSequence = Register(RootCodespace, 3, "invalid sequence")
// ErrUnauthorized is used whenever a request without sufficient
// authorization is handled.
ErrUnauthorized = Register(RootCodespace, 4, "unauthorized")
// ErrInsufficientFunds is used when the account cannot pay requested amount.
ErrInsufficientFunds = Register(RootCodespace, 5, "insufficient funds")
// ErrUnknownRequest to doc
ErrUnknownRequest = Register(RootCodespace, 6, "unknown request")
// ErrInvalidAddress to doc
ErrInvalidAddress = Register(RootCodespace, 7, "invalid address")
// ErrInvalidPubKey to doc
ErrInvalidPubKey = Register(RootCodespace, 8, "invalid pubkey")
// ErrUnknownAddress to doc
ErrUnknownAddress = Register(RootCodespace, 9, "unknown address")
// ErrInvalidCoins to doc
ErrInvalidCoins = Register(RootCodespace, 10, "invalid coins")
// ErrOutOfGas to doc
ErrOutOfGas = Register(RootCodespace, 11, "out of gas")
// ErrMemoTooLarge to doc
ErrMemoTooLarge = Register(RootCodespace, 12, "memo too large")
// ErrInsufficientFee to doc
ErrInsufficientFee = Register(RootCodespace, 13, "insufficient fee")
// ErrTooManySignatures to doc
ErrTooManySignatures = Register(RootCodespace, 14, "maximum number of signatures exceeded")
// ErrNoSignatures to doc
ErrNoSignatures = Register(RootCodespace, 15, "no signatures supplied")
// ErrJSONMarshal defines an ABCI typed JSON marshalling error
ErrJSONMarshal = Register(RootCodespace, 16, "failed to marshal JSON bytes")
// ErrJSONUnmarshal defines an ABCI typed JSON unmarshalling error
ErrJSONUnmarshal = Register(RootCodespace, 17, "failed to unmarshal JSON bytes")
// ErrInvalidRequest defines an ABCI typed error where the request contains
// invalid data.
ErrInvalidRequest = Register(RootCodespace, 18, "invalid request")
// ErrTxInMempoolCache defines an ABCI typed error where a tx already exists
// in the mempool.
ErrTxInMempoolCache = Register(RootCodespace, 19, "tx already in mempool")
// ErrMempoolIsFull defines an ABCI typed error where the mempool is full.
ErrMempoolIsFull = Register(RootCodespace, 20, "mempool is full")
// ErrTxTooLarge defines an ABCI typed error where tx is too large.
ErrTxTooLarge = Register(RootCodespace, 21, "tx too large")
// ErrKeyNotFound defines an error when the key doesn't exist
ErrKeyNotFound = Register(RootCodespace, 22, "key not found")
// ErrWrongPassword defines an error when the key password is invalid.
ErrWrongPassword = Register(RootCodespace, 23, "invalid account password")
// ErrorInvalidSigner defines an error when the tx intended signer does not match the given signer.
ErrorInvalidSigner = Register(RootCodespace, 24, "tx intended signer does not match the given signer")
// ErrorInvalidGasAdjustment defines an error for an invalid gas adjustment
ErrorInvalidGasAdjustment = Register(RootCodespace, 25, "invalid gas adjustment")
// ErrInvalidHeight defines an error for an invalid height
ErrInvalidHeight = Register(RootCodespace, 26, "invalid height")
// ErrInvalidVersion defines a general error for an invalid version
ErrInvalidVersion = Register(RootCodespace, 27, "invalid version")
// ErrInvalidChainID defines an error when the chain-id is invalid.
ErrInvalidChainID = Register(RootCodespace, 28, "invalid chain-id")
// ErrInvalidType defines an error an invalid type.
ErrInvalidType = Register(RootCodespace, 29, "invalid type")
// ErrTxTimeoutHeight defines an error for when a tx is rejected out due to an
// explicitly set timeout height.
ErrTxTimeoutHeight = Register(RootCodespace, 30, "tx timeout height")
// ErrUnknownExtensionOptions defines an error for unknown extension options.
ErrUnknownExtensionOptions = Register(RootCodespace, 31, "unknown extension options")
// ErrWrongSequence defines an error where the account sequence defined in
// the signer info doesn't match the account's actual sequence number.
ErrWrongSequence = Register(RootCodespace, 32, "incorrect account sequence")
// ErrPackAny defines an error when packing a protobuf message to Any fails.
ErrPackAny = Register(RootCodespace, 33, "failed packing protobuf message to Any")
// ErrUnpackAny defines an error when unpacking a protobuf message from Any fails.
ErrUnpackAny = Register(RootCodespace, 34, "failed unpacking protobuf message from Any")
// ErrLogic defines an internal logic error, e.g. an invariant or assertion
// that is violated. It is a programmer error, not a user-facing error.
ErrLogic = Register(RootCodespace, 35, "internal logic error")
// ErrConflict defines a conflict error, e.g. when two goroutines try to access
// the same resource and one of them fails.
ErrConflict = Register(RootCodespace, 36, "conflict")
// ErrNotSupported is returned when we call a branch of a code which is currently not
// supported.
ErrNotSupported = Register(RootCodespace, 37, "feature not supported")
// ErrNotFound defines an error when requested entity doesn't exist in the state.
ErrNotFound = Register(RootCodespace, 38, "not found")
// ErrIO should be used to wrap internal errors caused by external operation.
// Examples: not DB domain error, file writing etc...
ErrIO = Register(RootCodespace, 39, "Internal IO error")
// ErrAppConfig defines an error occurred if min-gas-prices field in BaseConfig is empty.
ErrAppConfig = Register(RootCodespace, 40, "error in app.toml")
// ErrPanic is only set when we recover from a panic, so we know to
// redact potentially sensitive system info
ErrPanic = errorsmod.ErrPanic
)