user7412: Is there a way to make bitcoin-cli output JSON-serialized errors? For example if I do
bitcoin-cli getblock foo

the output is
error code: -5
error message:
Block not found

I want the output to be something more like:
{
  "error": {
    "code": -5,
    "message": "Block not found"
  }
}

Behind the scenes, that's what the RPC response body looks like, and I want to tell bitcoin-cli, "Don't pretty-print the error if there is one. Just give me the JSON response." 

user7412: bitcoin-cli does not currently support dumping the raw JSON-RPC response. The relevant section of the Bitcoin Core code is here https://github.com/bitcoin/bitcoin/blob/2753285be72dd051cf2987ca5c80d0b149914020/src/bitcoin-cli.cpp#L455 .

7412: <p>Is there a way to make <code>bitcoin-cli</code> output JSON-serialized errors? For example if I do</p>

<pre><code>bitcoin-cli getblock foo
</code></pre>

<p>the output is</p>

<pre><code>error code: -5
error message:
Block not found
</code></pre>

<p>I want the output to be something more like:</p>

<pre><code>{
  "error": {
    "code": -5,
    "message": "Block not found"
  }
}
</code></pre>

<p>Behind the scenes, that's what the RPC response body looks like, and I want to tell bitcoin-cli, "Don't pretty-print the error if there is one. Just give me the JSON response." </p>
 7412: <p><code>bitcoin-cli</code> does not currently support dumping the raw JSON-RPC response. The relevant section of the Bitcoin Core code is here <a href="https://github.com/bitcoin/bitcoin/blob/2753285be72dd051cf2987ca5c80d0b149914020/src/bitcoin-cli.cpp#L455" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/2753285be72dd051cf2987ca5c80d0b149914020/src/bitcoin-cli.cpp#L455</a> .</p>
