openlegends_api/user/register/request/data/
error.rs1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug)]
4pub enum Error {
5 Json(serde_json::Error),
6 Regex(regex::Error),
7 Username(String),
8 Password(String),
9}
10
11impl Display for Error {
12 fn fmt(&self, f: &mut Formatter) -> Result {
13 match self {
14 Self::Json(e) => write!(f, "JSON error: `{e}`"),
15 Self::Regex(e) => write!(f, "Could not parse regex expression `{e}`"),
16 Self::Username(pattern) => write!(f, "Username does not match pattern `{pattern}`"),
17 Self::Password(pattern) => write!(f, "Password does not match pattern `{pattern}`"),
18 }
19 }
20}