#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
Bitcoind(bitcoind::Error),
ElectrumClient(electrum_client::Error),
BitcoinCoreRpc(bitcoind::bitcoincore_rpc::Error),
#[cfg(not(target_os = "windows"))]
Nix(nix::Error),
EarlyExit(std::process::ExitStatus),
BothDirsSpecified,
NoElectrsExecutableFound,
BothEnvVars,
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Io(e) => Some(e),
Error::Bitcoind(e) => Some(e),
Error::ElectrumClient(e) => Some(e),
Error::BitcoinCoreRpc(e) => Some(e),
#[cfg(not(target_os = "windows"))]
Error::Nix(e) => Some(e),
_ => None,
}
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<bitcoind::Error> for Error {
fn from(e: bitcoind::Error) -> Self {
Error::Bitcoind(e)
}
}
impl From<electrum_client::Error> for Error {
fn from(e: electrum_client::Error) -> Self {
Error::ElectrumClient(e)
}
}
impl From<bitcoind::bitcoincore_rpc::Error> for Error {
fn from(e: bitcoind::bitcoincore_rpc::Error) -> Self {
Error::BitcoinCoreRpc(e)
}
}
#[cfg(not(target_os = "windows"))]
impl From<nix::Error> for Error {
fn from(e: nix::Error) -> Self {
Error::Nix(e)
}
}