use std::fmt::Debug;
use std::hash::Hash;
#[cfg(feature = "_config")]
use std::io;
#[cfg(feature = "_config")]
use internet2::transport;
#[cfg(feature = "node")]
use crate::rpc;
pub trait Error: std::error::Error + Sized {}
#[cfg(feature = "_config")]
#[derive(Clone, Debug, Display, Error, From)]
#[display(doc_comments)]
#[non_exhaustive] pub enum ConfigInitError {
Io(String),
#[cfg(feature = "toml")]
#[from]
Toml(toml::ser::Error),
}
#[cfg(feature = "_config")]
impl From<io::Error> for ConfigInitError {
fn from(err: io::Error) -> Self { Self::Io(err.to_string()) }
}
#[cfg(feature = "_config")]
#[derive(Debug, Display, Error, From)]
#[display(doc_comments)]
#[non_exhaustive] pub enum BootstrapError<AppLevelError>
where
AppLevelError: Error,
{
#[cfg(feature = "shell")] #[from]
Config(settings::ConfigError),
#[from]
ConfigInit(ConfigInitError),
TorNotYetSupported,
Io(String),
#[from]
ArgParse(String),
#[cfg(feature = "zmq")]
#[from]
Zmq(zmq::Error),
Multithread,
#[from]
Transport(transport::Error),
#[from]
AppLevel(AppLevelError),
}
#[cfg(feature = "_config")]
impl<E> From<&str> for BootstrapError<E>
where
E: Error,
{
fn from(err: &str) -> Self { BootstrapError::ArgParse(err.to_string()) }
}
#[cfg(feature = "_config")]
impl<E> From<io::Error> for BootstrapError<E>
where
E: Error,
{
fn from(err: io::Error) -> Self { Self::Io(err.to_string()) }
}
#[cfg(feature = "node")]
#[derive(Clone, Debug, Display, Error, From)]
#[display(doc_comments)]
#[non_exhaustive]
pub enum RuntimeError<AppLevelError>
where
AppLevelError: Error,
{
#[cfg(feature = "zmq")]
#[from]
Zmq(zmq::Error),
#[from]
Rpc(rpc::ClientError),
#[from]
AppLevel(AppLevelError),
}
#[derive(Clone, PartialEq, Eq, Hash, Debug, Display, Error, From)]
#[display(doc_comments)]
pub enum DataParseError {
UnknownFormat,
NotSupported(String),
}