bsc/
error.rs

1use std::io;
2
3#[derive(Debug)]
4pub enum Error {
5    Io(io::Error),
6    Bs(String),
7}
8
9impl std::error::Error for Error {}
10
11impl std::fmt::Display for Error {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        match self {
14            Error::Io(err) => err.fmt(f),
15            Error::Bs(err) => err.fmt(f),
16        }
17    }
18}
19
20impl From<io::Error> for Error {
21    fn from(value: io::Error) -> Self {
22        Self::Io(value)
23    }
24}
25
26impl From<std::num::ParseIntError> for Error {
27    fn from(value: std::num::ParseIntError) -> Self {
28        Self::Bs(value.to_string())
29    }
30}
31
32impl From<&str> for Error {
33    fn from(value: &str) -> Self {
34        Self::Bs(value.to_string())
35    }
36}
37
38impl From<String> for Error {
39    fn from(value: String) -> Self {
40        Self::Bs(value)
41    }
42}
43
44impl From<serde_yaml::Error> for Error {
45    fn from(value: serde_yaml::Error) -> Self {
46        Self::Bs(value.to_string())
47    }
48}