1use std::fmt;
2
3#[derive(Debug)]
5pub enum NanoError {
6 Agent(String),
8 Provider(String),
10 Timeout,
12 Other(String),
14}
15
16impl fmt::Display for NanoError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 NanoError::Agent(msg) => write!(f, "agent error: {msg}"),
20 NanoError::Provider(msg) => write!(f, "provider error: {msg}"),
21 NanoError::Timeout => write!(f, "request timed out"),
22 NanoError::Other(msg) => write!(f, "{msg}"),
23 }
24 }
25}
26
27impl std::error::Error for NanoError {}
28
29impl From<anyhow::Error> for NanoError {
30 fn from(err: anyhow::Error) -> Self {
31 NanoError::Other(err.to_string())
32 }
33}