use std::fmt;
#[derive(Debug)]
pub enum NanoError {
Agent(String),
Provider(String),
Timeout,
Other(String),
}
impl fmt::Display for NanoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NanoError::Agent(msg) => write!(f, "agent error: {msg}"),
NanoError::Provider(msg) => write!(f, "provider error: {msg}"),
NanoError::Timeout => write!(f, "request timed out"),
NanoError::Other(msg) => write!(f, "{msg}"),
}
}
}
impl std::error::Error for NanoError {}
impl From<anyhow::Error> for NanoError {
fn from(err: anyhow::Error) -> Self {
NanoError::Other(err.to_string())
}
}