rocket_recaptcha_v3/
errors.rs1use std::{
2 error::Error,
3 fmt::{Display, Error as FmtError, Formatter},
4};
5
6#[derive(Debug, Clone)]
7pub enum ReCaptchaError {
9 InvalidInputSecret,
11 InvalidReCaptchaToken,
13 TimeoutOrDuplicate,
15 InternalError(String),
17}
18
19impl Display for ReCaptchaError {
20 #[inline]
21 fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
22 match self {
23 ReCaptchaError::InvalidInputSecret => f.write_str("The secret key is invalid."),
24 ReCaptchaError::InvalidReCaptchaToken => f.write_str("The reCAPTCHA token is invalid."),
25 ReCaptchaError::TimeoutOrDuplicate => {
26 f.write_str("The reCAPTCHA token is no longer valid.")
27 },
28 ReCaptchaError::InternalError(text) => f.write_str(text),
29 }
30 }
31}
32
33impl Error for ReCaptchaError {}