1#[derive(Debug)]
3pub enum Error {
4 Io(std::io::Error),
6
7 Bitcoind(corepc_node::Error),
9
10 ElectrumClient(electrum_client::Error),
12
13 #[cfg(not(target_os = "windows"))]
15 Nix(nix::Error),
16
17 EarlyExit(std::process::ExitStatus),
19
20 BothDirsSpecified,
22
23 NoElectrsExecutableFound,
26
27 BothEnvVars,
29}
30
31impl std::error::Error for Error {
32 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
33 match self {
34 Error::Io(e) => Some(e),
35 Error::Bitcoind(e) => Some(e),
36 Error::ElectrumClient(e) => Some(e),
37 #[cfg(not(target_os = "windows"))]
39 Error::Nix(e) => Some(e),
40
41 _ => None,
42 }
43 }
44}
45
46impl std::fmt::Display for Error {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 write!(f, "{:?}", self)
49 }
50}
51
52impl From<std::io::Error> for Error {
53 fn from(e: std::io::Error) -> Self {
54 Error::Io(e)
55 }
56}
57
58impl From<corepc_node::Error> for Error {
59 fn from(e: corepc_node::Error) -> Self {
60 Error::Bitcoind(e)
61 }
62}
63
64impl From<electrum_client::Error> for Error {
65 fn from(e: electrum_client::Error) -> Self {
66 Error::ElectrumClient(e)
67 }
68}
69
70#[cfg(not(target_os = "windows"))]
71impl From<nix::Error> for Error {
72 fn from(e: nix::Error) -> Self {
73 Error::Nix(e)
74 }
75}