urma_node_client/
error.rs1#[derive(Debug)]
2pub enum Error {
3 Io(std::io::Error),
4 Json(serde_json::Error),
5 Invalid(String),
6 Busy(String),
7}
8
9impl std::fmt::Display for Error {
10 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11 match self {
12 Self::Io(error) => write!(f, "local node I/O: {error}"),
13 Self::Json(error) => write!(f, "local node encoding: {error}"),
14 Self::Invalid(message) => f.write_str(message),
15 Self::Busy(message) => write!(f, "local node busy: {message}"),
16 }
17 }
18}
19impl std::error::Error for Error {
20 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
21 match self {
22 Self::Io(error) => Some(error),
23 Self::Json(error) => Some(error),
24 _ => None,
25 }
26 }
27}
28impl From<std::io::Error> for Error {
29 fn from(error: std::io::Error) -> Self {
30 Self::Io(error)
31 }
32}
33impl From<serde_json::Error> for Error {
34 fn from(error: serde_json::Error) -> Self {
35 Self::Json(error)
36 }
37}