1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::num::ParseIntError;
use std::io;
#[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "unexpected hex color format: expected({}), got({})", expected, actual)]
InvalidHexFormat {
actual: String,
expected: String,
},
#[fail(display = "couldn't parse hex value: {}", _0)]
Parse(ParseIntError),
#[fail(display = "IO error: {}", _0)]
IO(io::Error)
}
impl From<ParseIntError> for Error {
fn from(error: ParseIntError) -> Self {
Error::Parse(error)
}
}
impl From<io::Error> for Error {
fn from(error: io::Error) -> Self {
Error::IO(error)
}
}