simple_jsonrpc_client/
error.rs1use jsonrpc_core::Error as JsonRPCError;
2use reqwest::Error as ConnectionError;
3use serde_json::Error as SerdeError;
4use std::fmt;
5
6#[derive(Debug)]
7pub enum Error {
8 Jsonrpc(JsonRPCError),
9 Serialize(SerdeError),
10 Connection(ConnectionError),
11}
12
13impl fmt::Display for Error {
14 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15 match self {
16 Self::Jsonrpc(err) => write!(f, "{}", err)?,
17 Self::Serialize(err) => write!(f, "{}", err)?,
18 Self::Connection(err) => write!(f, "{}", err)?,
19 }
20 Ok(())
21 }
22}
23
24impl ::std::error::Error for Error {}
25
26impl From<JsonRPCError> for Error {
27 fn from(err: JsonRPCError) -> Self {
28 Error::Jsonrpc(err)
29 }
30}
31
32impl From<SerdeError> for Error {
33 fn from(err: SerdeError) -> Self {
34 Error::Serialize(err)
35 }
36}
37
38impl From<ConnectionError> for Error {
39 fn from(err: ConnectionError) -> Self {
40 Error::Connection(err)
41 }
42}