ascii_izer/
error.rs

1use std::{error::Error, fmt::Display, io};
2
3use image::ImageError;
4
5#[derive(Debug)]
6pub enum ASCIIError {
7    ImageError(ImageError),
8    IOError(io::Error),
9}
10
11impl Error for ASCIIError {}
12
13impl Display for ASCIIError {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        match self {
16            ASCIIError::ImageError(error) => {
17                write!(f, "{error}")
18            }
19            ASCIIError::IOError(error) => {
20                write!(f, "{error}")
21            }
22        }
23    }
24}
25
26impl From<ImageError> for ASCIIError {
27    fn from(value: ImageError) -> Self {
28        Self::ImageError(value)
29    }
30}
31
32impl From<io::Error> for ASCIIError {
33    fn from(value: io::Error) -> Self {
34        Self::IOError(value)
35    }
36}