1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::error::Error;
use std::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 {}