summaryrefslogtreecommitdiff
path: root/dichroism/src/error.rs
blob: 0cdd26923457cbd18ac503c62dd2250b7e81c4aa (plain) (blame)
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
#[derive(Debug)]
pub enum DichroismError {
    UriDataExtract(String),
    ImageWrite(String),
}

impl std::error::Error for DichroismError {}

impl std::fmt::Display for DichroismError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self)
    }
}

impl From<image::ImageError> for DichroismError {
    fn from(e: image::ImageError) -> Self {
        Self::ImageWrite(e.to_string())
    }
}

impl From<base64::DecodeError> for DichroismError {
    fn from(e: base64::DecodeError) -> Self {
        Self::UriDataExtract(e.to_string())
    }
}