1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use thiserror::Error;
use warp::{
    reject::{self, Reject},
    Rejection,
};

/// Error type that converts to a warp::Rejection
#[derive(Error, Debug)]
pub enum SessionError {
    #[error("Failed to load session")]
    LoadError { source: async_session::Error },

    #[error("Failed to store session")]
    StoreError { source: async_session::Error },

    #[error("Failed to destroy session")]
    DestroyError { source: async_session::Error },
}

impl Reject for SessionError {}

impl std::convert::From<SessionError> for Rejection {
    fn from(error: SessionError) -> Self {
        reject::custom(error)
    }
}