Skip to content

Commit fe37fbe

Browse files
committed
bitcoin-cli: Make error message less confusing
Sorry for the churn on this, but the current message (introduced in bitcoin#9073) isn't acceptable: $ src/bitcoin-cli getinfo rpc: couldn't connect to server (make sure server is running and you are connecting to the correct RPC port: -1 unknown) Putting the error code after the words "RPC port" made me wonder whether there was a port configuration issue. This changes it to: $ src/bitcoin-cli getinfo error: couldn't connect to server: unknown (code -1) (make sure server is running and you are connecting to the correct RPC port)
1 parent 3fbf079 commit fe37fbe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
247247
event_base_free(base);
248248

249249
if (response.status == 0)
250-
throw CConnectionFailed(strprintf("couldn't connect to server\n(make sure server is running and you are connecting to the correct RPC port: %d %s)", response.error, http_errorstring(response.error)));
250+
throw CConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error));
251251
else if (response.status == HTTP_UNAUTHORIZED)
252252
throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
253253
else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR)

0 commit comments

Comments
 (0)