1use std::{fmt, io};
2
3#[derive(Debug)]
4pub enum Error {
5 BadFormat(String),
6 IO(String),
8 JobsFailed
9}
10
11impl Error {
12 pub fn bad_format<S: ToString>(s: S) -> Self {
13 Error::BadFormat(s.to_string())
14 }
15}
16
17impl std::error::Error for Error {}
18
19impl From<io::Error> for Error {
20 fn from(err: io::Error) -> Self {
21 Error::IO(err.to_string())
22 }
23}
24
25impl fmt::Display for Error {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 match self {
28 Error::BadFormat(s) => {
29 write!(f, "Bad format error; {}", s)
30 }
31 Error::IO(s) => {
32 write!(f, "I/O error; {}", s)
33 }
34 Error::JobsFailed => {
35 write!(f, "One or more jobs failed")
36 }
37 }
38 }
39}
40
41