11//! Error types for the Bitcoin RPC client.
22
3- use bitcoin:: {
4- consensus:: encode:: FromHexError ,
5- hex:: { HexToArrayError , HexToBytesError } ,
6- } ;
3+ use bitcoin:: { consensus:: encode:: FromHexError , hex:: HexToArrayError } ;
74#[ cfg( feature = "28_0" ) ]
85use corepc_types:: v17:: { GetBlockHeaderVerboseError , GetBlockVerboseOneError } ;
96#[ cfg( not( feature = "28_0" ) ) ]
@@ -22,13 +19,13 @@ pub enum Error {
2219 DecodeHex ( FromHexError ) ,
2320
2421 /// Error converting `GetBlockVersboseOne` type into the model type
25- GetBlockVerboseOneError ( GetBlockVerboseOneError ) ,
22+ GetBlockVerboseOne ( GetBlockVerboseOneError ) ,
2623
2724 /// Error modeling [`GetBlockHeaderVerbose`](corepc_types::model::GetBlockHeaderVerbose).
28- GetBlockHeaderVerboseError ( GetBlockHeaderVerboseError ) ,
25+ GetBlockHeaderVerbose ( GetBlockHeaderVerboseError ) ,
2926
3027 /// Error modeling [`GetBlockFilter`](corepc_types::model::GetBlockFilter)
31- GetBlockFilterError ( GetBlockFilterError ) ,
28+ GetBlockFilter ( GetBlockFilterError ) ,
3229
3330 /// Missing authentication credentials.
3431 MissingAuthentication ,
@@ -42,9 +39,6 @@ pub enum Error {
4239 /// JSON-RPC error from the server.
4340 JsonRpc ( jsonrpc:: Error ) ,
4441
45- /// Hex decoding error for byte vectors (used in get_block, etc.)
46- HexToBytes ( HexToBytesError ) ,
47-
4842 /// Hash parsing error.
4943 HexToArray ( HexToArrayError ) ,
5044
@@ -55,7 +49,7 @@ pub enum Error {
5549 Io ( io:: Error ) ,
5650
5751 /// Error when converting an integer type to a smaller type due to overflow.
58- Overflow ( TryFromIntError ) ,
52+ TryFromInt ( TryFromIntError ) ,
5953}
6054
6155impl fmt:: Display for Error {
@@ -66,33 +60,15 @@ impl fmt::Display for Error {
6660 }
6761 Error :: InvalidCookieFile => write ! ( f, "invalid cookie file" ) ,
6862 Error :: InvalidResponse ( e) => write ! ( f, "invalid response: {e}" ) ,
69- Error :: HexToBytes ( e) => write ! ( f, "Hex to bytes error: {e}" ) ,
7063 Error :: HexToArray ( e) => write ! ( f, "Hash parsing eror: {e}" ) ,
7164 Error :: JsonRpc ( e) => write ! ( f, "JSON-RPC error: {e}" ) ,
7265 Error :: Json ( e) => write ! ( f, "JSON error: {e}" ) ,
7366 Error :: Io ( e) => write ! ( f, "I/O error: {e}" ) ,
7467 Error :: DecodeHex ( e) => write ! ( f, "Hex deserialization error: {e}" ) ,
75- Error :: GetBlockHeaderVerboseError ( e) => write ! ( f, "{e}" ) ,
76- Error :: GetBlockVerboseOneError ( e) => write ! ( f, "{e}" ) ,
77- Error :: Overflow ( e) => write ! ( f, "Integer conversion overflow error: {e}" ) ,
78- Error :: GetBlockFilterError ( e) => write ! ( f, "{e}" ) ,
79- }
80- }
81- }
82-
83- impl std:: error:: Error for Error {
84- fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
85- match self {
86- Error :: JsonRpc ( e) => Some ( e) ,
87- Error :: Json ( e) => Some ( e) ,
88- Error :: Io ( e) => Some ( e) ,
89- Error :: HexToBytes ( e) => Some ( e) ,
90- Error :: HexToArray ( e) => Some ( e) ,
91- Error :: DecodeHex ( e) => Some ( e) ,
92- Error :: GetBlockVerboseOneError ( e) => Some ( e) ,
93- Error :: Overflow ( e) => Some ( e) ,
94- Error :: GetBlockFilterError ( e) => Some ( e) ,
95- _ => None ,
68+ Error :: GetBlockHeaderVerbose ( e) => write ! ( f, "{e}" ) ,
69+ Error :: GetBlockVerboseOne ( e) => write ! ( f, "{e}" ) ,
70+ Error :: TryFromInt ( e) => write ! ( f, "Integer conversion overflow error: {e}" ) ,
71+ Error :: GetBlockFilter ( e) => write ! ( f, "{e}" ) ,
9672 }
9773 }
9874}
@@ -124,13 +100,13 @@ impl From<io::Error> for Error {
124100
125101impl From < TryFromIntError > for Error {
126102 fn from ( e : TryFromIntError ) -> Self {
127- Error :: Overflow ( e)
103+ Error :: TryFromInt ( e)
128104 }
129105}
130106
131107impl From < GetBlockVerboseOneError > for Error {
132108 fn from ( e : GetBlockVerboseOneError ) -> Self {
133- Error :: GetBlockVerboseOneError ( e)
109+ Error :: GetBlockVerboseOne ( e)
134110 }
135111}
136112
0 commit comments