-
Notifications
You must be signed in to change notification settings - Fork 36.7k
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
[bitcoin-cli] improve error output #6387
[bitcoin-cli] improve error output #6387
Conversation
e7c244c
to
9c7d0dd
Compare
ACK |
@@ -190,6 +190,15 @@ int CommandLineRPC(int argc, char *argv[]) | |||
throw CConnectionFailed("server in warmup"); | |||
strPrint = "error: " + error.write(); |
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.
Maybe not print the whole object, when we print the nicely formatted error?
What has always held me back from doing this (sensible) thing is that scripts may be relying on bitcoin-cli's output for errors to be as it is.
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 line strPrint = "error: " + error.write();
get's overwritten at L198 when error.isObject()
(currently always).
Hmm... if someone relies on a/the output of a RPC client application like bitcoin-cli he should definitively rethink his API design and probably directly use the JSON RPC API.
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.
Ok, fair enough. utACK.
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.
Agree / @jonasschnelli
9c7d0dd
to
f3a004a
Compare
f3a004a
to
65ce021
Compare
Travis error was unrelated (see #6391) |
65ce021 [bitcoin-cli] improve error output (Jonas Schnelli)
Bitcoin 0.12 misc PRs 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6198 - bitcoin/bitcoin#6206 - bitcoin/bitcoin#5927 - bitcoin/bitcoin#6213 - bitcoin/bitcoin#6061 - bitcoin/bitcoin#6283 (partial, remainder was pulled in #929) - bitcoin/bitcoin#6272 - bitcoin/bitcoin#6316 - bitcoin/bitcoin#6133 - bitcoin/bitcoin#6387 - bitcoin/bitcoin#6401 - bitcoin/bitcoin#6434 - bitcoin/bitcoin#6372 - bitcoin/bitcoin#6447 - bitcoin/bitcoin#6149 - bitcoin/bitcoin#6468 Part of #2074.
[only affects bitcoin-cli]
At the moment, errors in bitcoin-cli are sent to stderr as compact json string. Example:
This PR would format the error message and error code so that it's better readable. Example after this PR: