use std::fmt;
use nostr::nips::nip47;
use nostr_relay_pool::pool;
#[derive(Debug)]
pub enum Error {
NIP47(nip47::Error),
Pool(pool::Error),
PrematureExit,
Timeout,
Handler(String),
}
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NIP47(e) => e.fmt(f),
Self::Pool(e) => e.fmt(f),
Self::PrematureExit => f.write_str("premature exit"),
Self::Timeout => f.write_str("timeout"),
Self::Handler(e) => f.write_str(e),
}
}
}
impl From<nip47::Error> for Error {
fn from(e: nip47::Error) -> Self {
Self::NIP47(e)
}
}
impl From<pool::Error> for Error {
fn from(e: pool::Error) -> Self {
Self::Pool(e)
}
}