<blockquote>
<p>Coming from <a href="https://bitcoin.stackexchange.com/questions/59683/can-i-find-a-list-of-possible-error-codes-and-their-meanings-for-bitcoin-cli">this question</a>, is there any comprehensive collection of what errors can each RPC command return?</p>
<p>For example. Let's say I want to run <code>getbestblockhash</code> or <code>getblockcount</code>. I'm unsure about what errors to expect.</p>
</blockquote>
<p>I don't think that such documentation  exists. You would have to read the source code for a particular RPC. Additionally, since some functions are shared between RPCs and can return specific errors, it may not be easy to enumerate all of the errors.</p>
<blockquote>
<p>Furthermore, I'm unsure if there's a generic error code that can be return in many cases (<code>RPC_MISC_ERROR</code> for example).</p>
</blockquote>
<p>If there's an error which doesn't have its own specific catching and checking (i.e. an exception is thrown that the RPC doesn't catch), then <code>RPC_MISC_ERROR</code> will be returned.</p>

CC BY-SA 4.0
2019-11-18T16:46:15.313Z
Thanks Andrew. I'll wait a bit to see if someone has done the heavy lifting :( Am I at least safe to assume that any unexpected error will default to `RPC_MISC_ERROR` ?
sr_gi
CC BY-SA 4.0
2019-11-18T16:49:05.500Z
Yes, you can assume that unexpected errors default to `RPC_MISC_ERROR`.
Ava Chow
CC BY-SA 4.0
2019-11-18T16:40:22.253Z
2019-11-18T16:40:22.253Z
2020-06-16T11:10:03.350Z
Ava Chow
<p>Coming from <a href="https://bitcoin.stackexchange.com/questions/59683/can-i-find-a-list-of-possible-error-codes-and-their-meanings-for-bitcoin-cli">this question</a>, is there any comprehensive collection of what errors can each RPC command return?</p>

<p>For example. Let's say I want to run <code>getbestblockhash</code> or <code>getblockcount</code>. I'm unsure about what errors to expect. Furthermore, I'm unsure if there's a generic error code that can be return in many cases (<code>RPC_MISC_ERROR</code> for example).</p>

<bitcoind><json-rpc>
RPC errors raised by each command
sr_gi
# RPC errors raised by each command

(Asked by: username_0 on 2019-11-18)

Coming from [this question](https://bitcoin.stackexchange.com/questions/59683/can-i-find-a-list-of-possible-error-codes-and-their-meanings-for-bitcoin-cli), is there any comprehensive collection of what errors can each RPC command return?

For example. Let's say I want to run `getbestblockhash` or `getblockcount`. I'm unsure about what errors to expect. Furthermore, I'm unsure if there's a generic error code that can be return in many cases (`RPC_MISC_ERROR` for example).

**Tags:** bitcoind, json-rpc


---

## 1 answers

### Answer by username_1 on 2019-11-18. Score: 2 | Accepted answer

> Coming from [this question](https://bitcoin.stackexchange.com/questions/59683/can-i-find-a-list-of-possible-error-codes-and-their-meanings-for-bitcoin-cli), is there any comprehensive collection of what errors can each RPC command return?
>
> For example. Let's say I want to run `getbestblockhash` or `getblockcount`. I'm unsure about what errors to expect.

I don't think that such documentation exists. You would have to read the source code for a particular RPC. Additionally, since some functions are shared between RPCs and can return specific errors, it may not be easy to enumerate all of the errors.

> Furthermore, I'm unsure if there's a generic error code that can be return in many cases (`RPC_MISC_ERROR` for example).

If there's an error which doesn't have its own specific catching and checking (i.e. an exception is thrown that the RPC doesn't catch), then `RPC_MISC_ERROR` will be returned.

> **Comments:**
> **username_0**: Thanks Andrew. I'll wait a bit to see if someone has done the heavy lifting :( Am I at least safe to assume that any unexpected error will default to `RPC_MISC_ERROR` ?  
> **username_1**: Yes, you can assume that unexpected errors default to `RPC_MISC_ERROR`.  

---

