Fix zcash-cli crash when printing help message
When a `zcash-cli` command fails, it attempts to print the help message for the command. However, making the `help` call can also fail, and there was a bug in this check, so that we tried to display the help message when the `help` call failed, and tried to display the error when the `help` call succeeded – both leading to an assertion failure. This also makes some minor changes to the output formatting. Fixes #6561
This commit is contained in:
parent
6ad60e7340
commit
14c11c385a
|
@ -212,12 +212,12 @@ UniValue ConvertValues(const std::string &strMethod, const std::vector<std::stri
|
|||
auto helpMsg = CallRPC("help", ConvertValues("help", {strMethod}));
|
||||
return "\n\n"
|
||||
+ (helpMsg.has_value()
|
||||
? strprintf(
|
||||
? "Usage: " + helpMsg.value().get_str()
|
||||
: strprintf(
|
||||
"An error occurred while attempting to retrieve the "
|
||||
"help text for %s: %s",
|
||||
strMethod,
|
||||
helpMsg.error().get_str())
|
||||
: helpMsg->get_str());
|
||||
helpMsg.error().get_str()));
|
||||
}
|
||||
}));
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue