1use std::error::Error;
4use std::fmt::Display;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum AuthError {
9 GenericError,
11 UserNotFound,
13 UserAlreadyExists,
15 InvalidToken,
17 SessionAlreadyExists,
19}
20
21impl Display for AuthError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 AuthError::GenericError => write!(f, "Unknown error"),
25 AuthError::UserNotFound => write!(f, "User not found"),
26 AuthError::UserAlreadyExists => write!(f, "User already exists"),
27 AuthError::InvalidToken => write!(f, "Invalid token"),
28 AuthError::SessionAlreadyExists => write!(f, "Session already exists"),
29 }
30 }
31}
32
33impl Error for AuthError {}