1#[derive(Debug)]
5pub enum Error {
6 IO(std::io::Error),
8 JSON(serde_json::Error),
10 Environment(std::env::VarError),
12 Message(String),
14 Generic(Box<dyn std::error::Error>)
16}
17
18impl From<&str> for Error {
19 fn from(s: &str) -> Self {
20 Self::Message(s.into())
21 }
22}
23
24impl From<String> for Error {
25 fn from(s: String) -> Self {
26 Self::Message(s)
27 }
28}
29
30impl From<std::io::Error> for Error {
31 fn from(error: std::io::Error) -> Self {
32 Self::IO(error)
33 }
34}
35
36impl From<serde_json::Error> for Error {
37 fn from(error: serde_json::Error) -> Self {
38 Self::JSON(error)
39 }
40}
41
42impl From<std::env::VarError> for Error {
43 fn from(error: std::env::VarError) -> Self {
44 Self::Environment(error)
45 }
46}
47
48pub type Result<T> = std::result::Result<T, Error>;