use std::fmt::{Debug, Display, Formatter};
#[derive(Debug)]
#[allow(missing_copy_implementations)]
pub enum Error<SessionStoreConnectorError> {
UpdatedSessionDoesNotExist,
MaximumSessionIdGenerationTriesReached,
SessionStoreConnector(SessionStoreConnectorError),
}
impl<SessionStoreConnectorError> From<SessionStoreConnectorError>
for Error<SessionStoreConnectorError>
{
fn from(error: SessionStoreConnectorError) -> Self {
Self::SessionStoreConnector(error)
}
}
impl<SessionStoreConnectorError: Display> Display for Error<SessionStoreConnectorError> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Error::UpdatedSessionDoesNotExist => write!(f, "the updated session does not exist, which indicates that it was concurrently modified or deleted."),
Error::MaximumSessionIdGenerationTriesReached => write!(f, "tried to generate a new session id but generated only existing ids until the maximum retry limit was reached."),
Error::SessionStoreConnector(error) => write!(f, "{error}"),
}
}
}
impl<SessionStoreConnectorError: Debug + Display> std::error::Error
for Error<SessionStoreConnectorError>
{
}