bitcoin_async_client/
error.rs

1// To the extent possible under law, the author(s) have dedicated all
2// copyright and related and neighboring rights to this software to
3// the public domain worldwide. This software is distributed without
4// any warranty.
5//
6// You should have received a copy of the CC0 Public Domain Dedication
7// along with this software.
8// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
9//
10
11use bitcoin::hashes::hex;
12use bitcoin::secp256k1;
13
14/// The error type for errors produced in this library.
15#[derive(Debug, thiserror::Error)]
16pub enum Error {
17    #[error("JSON-RPC error: {0}")]
18    Rpc(#[from] jsonrpsee::core::ClientError),
19
20    #[error("hex decode error: {0}")]
21    Hex(#[from] bitcoin::consensus::encode::FromHexError),
22
23    #[error("hex encode error: {0}")]
24    Hex2(#[from] hex::HexToBytesError),
25
26    #[error("JSON error: {0}")]
27    Json(#[from] serde_json::Error),
28
29    #[error("Bitcoin serialization error: {0}")]
30    BitcoinSerialization(#[from] bitcoin::consensus::encode::Error),
31
32    #[error("secp256k1 error: {0}")]
33    Secp256k1(#[from] secp256k1::Error),
34
35    #[error("I/O error: {0}")]
36    Io(#[from] std::io::Error),
37
38    #[error("invalid amount: {0}")]
39    InvalidAmount(#[from] bitcoin::amount::ParseAmountError),
40
41    #[error("invalid cookie file")]
42    InvalidCookieFile,
43
44    #[error("the JSON result had an unexpected structure")]
45    UnexpectedStructure,
46
47    #[error("the daemon returned an error string: {0}")]
48    ReturnedError(String),
49}