/
errors.go
104 lines (84 loc) · 2.92 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
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2016 The Decred developers
// Copyright (c) 2018 The ExchangeCoin team
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package legacyrpc
import (
"errors"
"github.com/EXCCoin/exccd/exccjson"
)
// TODO(jrick): There are several error paths which 'replace' various errors
// with a more appropiate error from the exccjson package. Create a map of
// these replacements so they can be handled once after an RPC handler has
// returned and before the error is marshaled.
// Error types to simplify the reporting of specific categories of
// errors, and their *exccjson.RPCError creation.
type (
// DeserializationError describes a failed deserializaion due to bad
// user input. It corresponds to exccjson.ErrRPCDeserialization.
DeserializationError struct {
error
}
// InvalidParameterError describes an invalid parameter passed by
// the user. It corresponds to exccjson.ErrRPCInvalidParameter.
InvalidParameterError struct {
error
}
// ParseError describes a failed parse due to bad user input. It
// corresponds to exccjson.ErrRPCParse.
ParseError struct {
error
}
)
// Errors variables that are defined once here to avoid duplication below.
var (
ErrNeedPositiveAmount = InvalidParameterError{
errors.New("amount must be positive"),
}
ErrNeedBelowMaxAmount = InvalidParameterError{
errors.New("amount must be below max amount"),
}
ErrNeedPositiveSpendLimit = InvalidParameterError{
errors.New("spend limit must be positive"),
}
ErrNeedPositiveMinconf = InvalidParameterError{
errors.New("minconf must be positive"),
}
ErrAddressNotInWallet = exccjson.RPCError{
Code: exccjson.ErrRPCWallet,
Message: "address not found in wallet",
}
ErrAccountNameNotFound = exccjson.RPCError{
Code: exccjson.ErrRPCWalletInvalidAccountName,
Message: "account name not found",
}
ErrUnloadedWallet = exccjson.RPCError{
Code: exccjson.ErrRPCWallet,
Message: "Request requires a wallet but wallet has not loaded yet",
}
ErrClientNotConnected = exccjson.RPCError{
Code: exccjson.ErrRPCClientNotConnected,
Message: "RPC client has not connected yet",
}
ErrWalletUnlockNeeded = exccjson.RPCError{
Code: exccjson.ErrRPCWalletUnlockNeeded,
Message: "Enter the wallet passphrase with walletpassphrase first",
}
ErrNotImportedAccount = exccjson.RPCError{
Code: exccjson.ErrRPCWallet,
Message: "imported addresses must belong to the imported account",
}
ErrNoTransactionInfo = exccjson.RPCError{
Code: exccjson.ErrRPCNoTxInfo,
Message: "No information for transaction",
}
ErrReservedAccountName = exccjson.RPCError{
Code: exccjson.ErrRPCInvalidParameter,
Message: "Account name is reserved by RPC server",
}
ErrMainNetSafety = exccjson.RPCError{
Code: exccjson.ErrRPCWallet,
Message: "RPC function disabled on MainNet wallets for security purposes",
}
)