Skip to main content

limitless_cli/utils/
errors.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum LimitlessError {
5    ToolNotFound(String),
6    ConfigError(String),
7    IoError(String),
8    ParseError(String),
9}
10
11impl fmt::Display for LimitlessError {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            LimitlessError::ToolNotFound(tool) => write!(f, "Tool not found: {}", tool),
15            LimitlessError::ConfigError(msg) => write!(f, "Config error: {}", msg),
16            LimitlessError::IoError(msg) => write!(f, "IO error: {}", msg),
17            LimitlessError::ParseError(msg) => write!(f, "Parse error: {}", msg),
18        }
19    }
20}
21
22impl std::error::Error for LimitlessError {}
23
24impl From<std::io::Error> for LimitlessError {
25    fn from(e: std::io::Error) -> Self {
26        LimitlessError::IoError(e.to_string())
27    }
28}