use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
Malformed(&'static str),
UnsupportedAlgorithm,
WrongType,
UnknownKey,
BadSignature,
BadClaim(&'static str),
LifetimeTooLong,
NotYetValid,
Expired,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Malformed(d) => write!(f, "malformed token: {d}"),
Self::UnsupportedAlgorithm => f.write_str("unsupported alg"),
Self::WrongType => f.write_str("wrong typ"),
Self::UnknownKey => f.write_str("unknown key"),
Self::BadSignature => f.write_str("bad signature"),
Self::BadClaim(d) => write!(f, "bad claim: {d}"),
Self::LifetimeTooLong => f.write_str("lifetime too long"),
Self::NotYetValid => f.write_str("not yet valid"),
Self::Expired => f.write_str("expired"),
}
}
}
impl std::error::Error for Error {}