diff options
| author | John Newbery <[email protected]> | 2017-02-07 12:57:37 -0500 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2017-06-05 19:01:16 +0000 |
| commit | 4943d7a9feb8e4f5461622f548032e53eb714175 (patch) | |
| tree | db2ede0515024288004c5181118b281be31706a3 /src/rpc/net.cpp | |
| parent | Return correct error codes in removeprunedfunds(). (diff) | |
| download | discoin-4943d7a9feb8e4f5461622f548032e53eb714175.tar.xz discoin-4943d7a9feb8e4f5461622f548032e53eb714175.zip | |
Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:
- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
enters an invalid IP address or subnet.
This commit also updates the test cases to explicitly test the error code.
This commit also adds a testcase for trying to setban on an invalid subnet.
Github-Pull: #9853
Rebased-From: a012087667edb35a36f25ae06b42b1644d80e649
Diffstat (limited to 'src/rpc/net.cpp')
| -rw-r--r-- | src/rpc/net.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 8706b4295..42f5db94f 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -506,7 +506,7 @@ UniValue setban(const JSONRPCRequest& request) LookupSubNet(request.params[0].get_str().c_str(), subNet); if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) ) - throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Invalid IP/Subnet"); + throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Invalid IP/Subnet"); if (strCommand == "add") { @@ -526,7 +526,7 @@ UniValue setban(const JSONRPCRequest& request) else if(strCommand == "remove") { if (!( isSubnet ? g_connman->Unban(subNet) : g_connman->Unban(netAddr) )) - throw JSONRPCError(RPC_MISC_ERROR, "Error: Unban failed"); + throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Unban failed. Requested address/subnet was not previously banned."); } return NullUniValue; } |