Skip to main content

hermes_agent_cli_core/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum CliError {
5    #[error("authentication error: {0}")]
6    Auth(String),
7
8    #[error("configuration error: {0}")]
9    Config(String),
10
11    #[error("command not found: {0}")]
12    CommandNotFound(String),
13
14    #[error("invalid argument: {0}")]
15    InvalidArgument(String),
16
17    #[error("network error: {0}")]
18    Network(String),
19
20    #[error("IO error: {0}")]
21    Io(#[from] std::io::Error),
22
23    #[error("serialization error: {0}")]
24    Serialization(String),
25}
26
27impl CliError {
28    pub fn auth(msg: impl Into<String>) -> Self {
29        CliError::Auth(msg.into())
30    }
31
32    pub fn config(msg: impl Into<String>) -> Self {
33        CliError::Config(msg.into())
34    }
35
36    pub fn invalid_arg(msg: impl Into<String>) -> Self {
37        CliError::InvalidArgument(msg.into())
38    }
39}