1use glyph_core::GlyphError;
2use std::env::VarError;
3use std::io;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum CliError {
8 #[error(transparent)]
9 Core(#[from] GlyphError),
10
11 #[error("IO error: {0}")]
12 Io(#[from] io::Error),
13
14 #[error("Environment error: {0}")]
15 Env(#[from] VarError),
16
17 #[error("Terminal error: {0}")]
18 Terminal(String),
19
20 #[error("Input error: {0}")]
21 Input(String),
22
23 #[error("File error: {0}")]
24 File(String),
25
26 #[error("Other error: {0}")]
27 Other(String),
28}
29
30pub type Result<T> = std::result::Result<T, CliError>;
31
32impl From<String> for CliError {
33 fn from(s: String) -> Self {
34 CliError::Input(s)
35 }
36}
37
38impl From<&str> for CliError {
39 fn from(s: &str) -> Self {
40 CliError::Input(s.to_string())
41 }
42}