-
Notifications
You must be signed in to change notification settings - Fork 38.8k
cli: improve bitcoin-cli error when not connected #29687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a string suggestion `bitcoin-cli -help` as an additional source of information.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
|
lgtm ACK 69d6fd6 |
cbergqvist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the first errors users are likely to encounter, so I support making it a bit more helpful.
| throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\n" | ||
| "Make sure the bitcoind server is running and that you are connecting to the correct RPC port.\n" | ||
| "Use \"bitcoin-cli -help\" for more info.", | ||
| host, port, responseErrorMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 tabs eh? :)
I suggest conforming with the throw-statement following the one being changed - putting the initial string literal on a new line and keep to one tab indentation.
| throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\n" | |
| "Make sure the bitcoind server is running and that you are connecting to the correct RPC port.\n" | |
| "Use \"bitcoin-cli -help\" for more info.", | |
| host, port, responseErrorMessage)); | |
| throw CConnectionFailed(strprintf( | |
| "Could not connect to the server %s:%d%s\n\n" | |
| "Make sure the bitcoind server is running and that you are connecting to the correct RPC port.\n" | |
| "Use \"bitcoin-cli -help\" for more info.", | |
| host, port, responseErrorMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format-diff has other ideas:
throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\n"
"Make sure the bitcoind server is running and that you are connecting to the correct RPC port.\n"
"Use \"bitcoin-cli -help\" for more info.",
host, port, responseErrorMessage));Not sure where the 3 tabs came from, as my check script is supposed to run that... I guess was my editor default somehow though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbergqvist Generally, the style is left to the pull request author and usually not changed, unless someone else touches it. Also, tabs \t are not allowed in C++ code in this repo. If there were any, the CI should have failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I regret the initial tone of my comment but I'm happy clang-format came up with something reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no worries :)
| throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\nMake sure the bitcoind server is running and that you are connecting to the correct RPC port.", host, port, responseErrorMessage)); | ||
| throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\n" | ||
| "Make sure the bitcoind server is running and that you are connecting to the correct RPC port.\n" | ||
| "Use \"bitcoin-cli -help\" for more info.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ++specificity
| "Use \"bitcoin-cli -help\" for more info.", | |
| "Use \"bitcoin-cli -help\" for more connection info.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "connection info" might be less accurate here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking the user might be missing -rpcport, -rpcconnect or -signet (different default port), but not -generate -netinfo or -stdin. Maybe -signet is not something one would classify as "connection info" though, making it less accurate as you say.
Adds a string suggestion `bitcoin-cli -help` as an additional source of information. Github-Pull: bitcoin#29687 Rebased-From: 69d6fd6
tdb3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK for 69d6fd6
Good light-touch approach to address Issue #29555.
Executed, and the output looks good:
$ src/bitcoin-cli help
error: timeout on transient error: Could not connect to the server 127.0.0.1:8332
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
Use "bitcoin-cli -help" for more info.Just to be thorough:
Pulled the pr branch, built, ran all unit and functional tests (all passed) before executing.
MarnixCroes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack 69d6fd6
|
tested ACK 69d6fd6 This a reasonable way for both reporting the connection failure, plus guiding the user on how to get more help on bitcoin-cli. Output
Tests
|
fa3e115 doc: Correct pull request prefix for scripts and tools (MarcoFalke) Pull request description: `script` is confusing, because in the context of Bitcoin, it usually means Bitcoin script (c.f. `CScript` in `script.h`, or pull requests such as #27122 using the prefix). This could be fixed by renaming it to `scripts` (with a plural `s` at the end), however, looking at the current usage `contrib` and `cli` seem more common (#29687, #26953, #26584, #24864, #30074, #29433 ...) ACKs for top commit: fanquake: ACK fa3e115 willcl-ark: ACK fa3e115 hebasto: ACK fa3e115. theuni: ACK fa3e115 Tree-SHA512: fb3a3892ca5f859e590c8a620350c397ef1f9eafd9e174c70ef50095d401a396758d6c93ad41888da8025c41e25e691f30c18f9e974af13597f2266bb2c53b6d
Closes: #29555
Simply adds an additional suggestion to check
bitcoin-cli -help.