image_changer/
misc.rs

1//! A module to contain general public API items
2
3use std::error;
4use std::fmt;
5
6#[derive(Debug)]
7pub struct ImgConversionError {
8    details: String,
9}
10
11impl ImgConversionError {
12    pub fn new(msg: &str) -> ImgConversionError {
13        ImgConversionError {
14            details: msg.to_string(),
15        }
16    }
17}
18
19impl fmt::Display for ImgConversionError {
20    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21        write!(f, "{}", self.details)
22    }
23}
24
25impl error::Error for ImgConversionError {
26    fn description(&self) -> &str {
27        &self.details
28    }
29}