use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
IllegalTransition {
from: &'static str,
to: &'static str,
},
Integrity { expected: String, actual: String },
NotFound { what: String },
Unauthorized,
Malformed { what: String },
Backend { detail: String },
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::IllegalTransition { from, to } => {
write!(f, "illegal state transition: {from} -> {to}")
}
Error::Integrity { expected, actual } => {
write!(
f,
"integrity check failed: expected {expected}, got {actual}"
)
}
Error::NotFound { what } => write!(f, "not found: {what}"),
Error::Unauthorized => f.write_str("unauthorized: a verified mID session is required"),
Error::Malformed { what } => write!(f, "malformed input: {what}"),
Error::Backend { detail } => write!(f, "backend error: {detail}"),
}
}
}
impl std::error::Error for Error {}