Skip to main content

dioxus_auth/
error.rs

1use std::fmt;
2
3pub type AuthResult<T> = Result<T, AuthError>;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
6pub enum AuthError {
7    MissingSession,
8    InvalidSession,
9    ExpiredSession,
10    Unauthenticated,
11    Store(String),
12}
13
14impl fmt::Display for AuthError {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        match self {
17            Self::MissingSession => f.write_str("missing authentication session"),
18            Self::InvalidSession => f.write_str("invalid authentication session"),
19            Self::ExpiredSession => f.write_str("expired authentication session"),
20            Self::Unauthenticated => f.write_str("user is not authenticated"),
21            Self::Store(message) => write!(f, "authentication store error: {message}"),
22        }
23    }
24}
25
26impl std::error::Error for AuthError {}