use std::{
error::Error,
fmt::{Display, Error as FmtError, Formatter},
};
#[derive(Debug, Clone)]
pub enum ReCaptchaError {
InvalidInputSecret,
InvalidReCaptchaToken,
TimeoutOrDuplicate,
InternalError(String),
}
impl Display for ReCaptchaError {
#[inline]
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
match self {
ReCaptchaError::InvalidInputSecret => f.write_str("The secret key is invalid."),
ReCaptchaError::InvalidReCaptchaToken => f.write_str("The reCAPTCHA token is invalid."),
ReCaptchaError::TimeoutOrDuplicate => {
f.write_str("The reCAPTCHA token is no longer valid.")
},
ReCaptchaError::InternalError(text) => f.write_str(text),
}
}
}
impl Error for ReCaptchaError {}