1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use ::std::error::Error;
use ::std::fmt::Display;
use ::std::fmt::Formatter;
use ::std::fmt::Result as FmtResult;

#[derive(Clone, Debug, PartialEq)]
pub enum EmailError {
    Invalid { raw_email: String },
}

impl Error for EmailError {}

impl Display for EmailError {
    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
        match self {
            EmailError::Invalid { raw_email } => {
                write!(f, "invalid email address, was given '{}'", raw_email)
            }
        }
    }
}