f9f9355
use thiserror::Error;
/// Errors that can occur while generating or verifying an Altcha PoW CAPTCHA.
#[derive(Debug, Error)]
pub enum PowError {
/// The HMAC secret is not configured. Challenges cannot be signed or
/// verified without one.
#[error("pow hmac secret is not configured")]
MissingSecret,
/// The configured algorithm is not supported by the underlying library.
#[error("unsupported pow algorithm: {0}")]
UnsupportedAlgorithm(String),
/// The challenge has expired.
#[error("pow challenge expired")]
Expired,
/// The challenge signature is missing or invalid.
#[error("invalid pow challenge signature")]
InvalidSignature,
/// The submitted solution does not satisfy the challenge.
#[error("invalid pow solution")]
InvalidSolution,
/// The challenge was not issued by the server (or was already consumed).
#[error("pow challenge was not issued or already used")]
NotIssued,
/// The challenge is bound to a different client than the caller.
#[error("pow challenge was issued for a different client")]
ClientMismatch,
/// The one-time challenge store reported an error.
#[error("pow store error: {0}")]
Storage(String),
/// The underlying altcha library reported an error.
#[error("pow error: {0}")]
Altcha(#[from] altcha::Error),
}