1#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error("IO error: {0}")]
10 Io(#[from] std::io::Error),
11
12 #[error("Configuration error: {0}")]
14 Config(String),
15
16 #[error("Validation error: {0}")]
18 Validation(String),
19
20 #[error("Template error: {0}")]
22 Template(String),
23
24 #[error("Update error: {0}")]
26 Update(String),
27
28 #[error("Standards violation: {0}")]
30 Standards(String),
31
32 #[error("CLI error: {0}")]
34 Cli(String),
35
36 #[error("Process error: {0}")]
38 Process(String),
39
40 #[error("Serialization error: {0}")]
42 Serialization(#[from] serde_json::Error),
43
44 #[error("TOML error: {0}")]
46 Toml(#[from] toml::de::Error),
47
48 #[error("Network error: {0}")]
50 Network(#[from] reqwest::Error),
51
52 #[error("Version error: {0}")]
54 Version(#[from] semver::Error),
55}
56
57pub type Result<T> = std::result::Result<T, Error>;
59
60impl Error {
61 pub fn config(msg: impl Into<String>) -> Self {
63 Self::Config(msg.into())
64 }
65
66 pub fn validation(msg: impl Into<String>) -> Self {
68 Self::Validation(msg.into())
69 }
70
71 pub fn template(msg: impl Into<String>) -> Self {
73 Self::Template(msg.into())
74 }
75
76 pub fn update(msg: impl Into<String>) -> Self {
78 Self::Update(msg.into())
79 }
80
81 pub fn standards(msg: impl Into<String>) -> Self {
83 Self::Standards(msg.into())
84 }
85
86 pub fn cli(msg: impl Into<String>) -> Self {
88 Self::Cli(msg.into())
89 }
90
91 pub fn process(msg: impl Into<String>) -> Self {
93 Self::Process(msg.into())
94 }
95}
96
97impl From<anyhow::Error> for Error {
99 fn from(err: anyhow::Error) -> Self {
100 Self::Process(err.to_string())
101 }
102}