-
Notifications
You must be signed in to change notification settings - Fork 202
/
errors.go
154 lines (109 loc) · 6.29 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
package state
import (
"encoding/hex"
"errors"
"fmt"
"github.com/ElrondNetwork/elrond-go/common"
)
// ErrMissingTrie is an error-compatible struct holding the root hash of the trie that is missing
type ErrMissingTrie struct {
rootHash []byte
}
// ------- ErrMissingTrie
// NewErrMissingTrie returns a new instantiated struct
func NewErrMissingTrie(rootHash []byte) *ErrMissingTrie {
return &ErrMissingTrie{rootHash: rootHash}
}
// Error returns the error as string
func (e *ErrMissingTrie) Error() string {
return "trie was not found for hash " + hex.EncodeToString(e.rootHash)
}
// ErrAccountNotFoundAtBlock is an error-compatible struct holding the block info at which an account was not found
type ErrAccountNotFoundAtBlock struct {
BlockInfo common.BlockInfo
}
// NewErrAccountNotFoundAtBlock returns a new error (custom struct)
func NewErrAccountNotFoundAtBlock(blockInfo common.BlockInfo) *ErrAccountNotFoundAtBlock {
return &ErrAccountNotFoundAtBlock{BlockInfo: blockInfo}
}
// Error returns the error as string
func (e *ErrAccountNotFoundAtBlock) Error() string {
return fmt.Sprintf("account was not found at block: nonce = %d, hash = %s, rootHash = %s",
e.BlockInfo.GetNonce(),
hex.EncodeToString(e.BlockInfo.GetHash()),
hex.EncodeToString(e.BlockInfo.GetRootHash()),
)
}
// ErrNilAccountsAdapter defines the error when trying to revert on nil accounts
var ErrNilAccountsAdapter = errors.New("nil AccountsAdapter")
// ErrNilAddress defines the error when trying to work with a nil address
var ErrNilAddress = errors.New("nil address")
// ErrEmptyAddress defines the error when trying to work with an empty address
var ErrEmptyAddress = errors.New("empty Address")
// ErrNilTrie signals that a trie is nil and no operation can be made
var ErrNilTrie = errors.New("trie is nil")
// ErrNilHasher signals that an operation has been attempted to or with a nil hasher implementation
var ErrNilHasher = errors.New("nil hasher")
// ErrNilMarshalizer signals that an operation has been attempted to or with a nil marshalizer implementation
var ErrNilMarshalizer = errors.New("nil marshalizer")
// ErrNegativeValue signals that an operation has been attempted with a negative value
var ErrNegativeValue = errors.New("negative values are not permited")
// ErrNilAccountFactory signals that a nil account factory was provided
var ErrNilAccountFactory = errors.New("account factory is nil")
// ErrNilUpdater signals that a nil updater has been provided
var ErrNilUpdater = errors.New("updater is nil")
// ErrNilAccountHandler signals that a nil account wrapper was provided
var ErrNilAccountHandler = errors.New("account wrapper is nil")
// ErrNilShardCoordinator signals that nil shard coordinator was provided
var ErrNilShardCoordinator = errors.New("shard coordinator is nil")
// ErrWrongTypeAssertion signals that a wrong type assertion occurred
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
// ErrNilTrackableDataTrie signals that a nil trackable data trie has been provided
var ErrNilTrackableDataTrie = errors.New("nil trackable data trie")
// ErrAccNotFound signals that account was not found in state trie
var ErrAccNotFound = errors.New("account was not found")
// ErrNilBLSPublicKey signals that the provided BLS public key is nil
var ErrNilBLSPublicKey = errors.New("bls public key is nil")
// ErrNilOrEmptyDataTrieUpdates signals that there are no data trie updates
var ErrNilOrEmptyDataTrieUpdates = errors.New("no data trie updates")
// ErrOperationNotPermitted signals that operation is not permitted
var ErrOperationNotPermitted = errors.New("operation in account not permitted")
// ErrInvalidAddressLength signals that address length is invalid
var ErrInvalidAddressLength = errors.New("invalid address length")
// ErrInsufficientFunds signals the funds are insufficient for the move balance operation but the
// transaction fee is covered by the current balance
var ErrInsufficientFunds = errors.New("insufficient funds")
// ErrNilStorageManager signals that nil storage manager has been provided
var ErrNilStorageManager = errors.New("nil storage manager")
// ErrNilRequestHandler signals that nil request handler has been provided
var ErrNilRequestHandler = errors.New("nil request handler")
// ErrNilCacher signals that nil cacher has been provided
var ErrNilCacher = errors.New("nil cacher")
// ErrSnapshotValueOutOfBounds signals that the snapshot value is out of bounds
var ErrSnapshotValueOutOfBounds = errors.New("snapshot value out of bounds")
// ErrInvalidPubkeyConverterType signals that the provided pubkey converter type is invalid
var ErrInvalidPubkeyConverterType = errors.New("invalid pubkey converter type")
// ErrNilMapOfHashes signals that the provided map of hashes is nil
var ErrNilMapOfHashes = errors.New("nil map of hashes")
// ErrInvalidRootHash signals that the provided root hash is invalid
var ErrInvalidRootHash = errors.New("invalid root hash")
// ErrInvalidMaxHardCapForMissingNodes signals that the maximum hardcap value for missing nodes is invalid
var ErrInvalidMaxHardCapForMissingNodes = errors.New("invalid max hardcap for missing nodes")
// ErrNilEvictionWaitingList is raised when a nil eviction waiting list is provided
var ErrNilEvictionWaitingList = errors.New("nil eviction waiting list provided")
// ErrInvalidIdentifier signals that the root hash has an invalid identifier
var ErrInvalidIdentifier = errors.New("invalid identifier")
// ErrNilStoragePruningManager signals that a nil storagePruningManager was provided
var ErrNilStoragePruningManager = errors.New("nil storagePruningManager")
// ErrInvalidKey is raised when the given key is invalid
var ErrInvalidKey = errors.New("invalid key")
// ErrNilRootHash signals that a nil root hash was provided
var ErrNilRootHash = errors.New("nil root hash")
// ErrNilProcessStatusHandler signals that a nil process status handler was provided
var ErrNilProcessStatusHandler = errors.New("nil process status handler")
// ErrNilBlockInfo signals that a nil block info was provided
var ErrNilBlockInfo = errors.New("nil block info")
// ErrNilBlockInfoProvider signals that a nil block info provider was provided
var ErrNilBlockInfoProvider = errors.New("nil block info provider")
// ErrFunctionalityNotImplemented signals that the functionality has not been implemented yet
var ErrFunctionalityNotImplemented = errors.New("functionality not implemented yet")