rem_utils/
error.rs

1use std::string::FromUtf8Error;
2
3#[derive(Debug)]
4pub enum Error {
5    IO(std::io::Error),
6    StringFormat(FromUtf8Error),
7    TypeError(crate::typ::Error),
8    Other(String),
9}
10impl From<Error> for String {
11    fn from(val: Error) -> Self {
12        match val {
13            Error::IO(ioe) => format!("IO({:?})", ioe),
14            Error::TypeError(e) => format!("TypeError({:?})", e),
15            Error::StringFormat(f) => format!("{:?}", f),
16            Error::Other(st) => format!("Other Error: {}", st),
17        }
18    }
19}
20
21impl From<crate::typ::Error> for Error {
22    fn from(val: crate::typ::Error) -> Self {
23        Error::TypeError(val)
24    }
25}
26
27impl From<std::io::Error> for Error {
28    fn from(v: std::io::Error) -> Self {
29        Error::IO(v)
30    }
31}
32impl From<FromUtf8Error> for Error {
33    fn from(v: FromUtf8Error) -> Self {
34        Error::StringFormat(v)
35    }
36}
37impl From<String> for Error {
38    fn from(v: String) -> Self {
39        Error::Other(v)
40    }
41}
42
43impl<'a> From<&'a str> for Error {
44    fn from(v: &'a str) -> Self {
45        Error::Other(v.into())
46    }
47}
48
49impl From<!> for Error {
50    fn from(v: !) -> Self {
51        match v {}
52    }
53}