openauth_plugins/captcha/
error.rs1#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
4pub enum CaptchaConfigError {
5 #[error("missing CAPTCHA secret key")]
6 MissingSecretKey,
7 #[error("failed to serialize CAPTCHA options: {0}")]
8 SerializeOptions(String),
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub enum CaptchaErrorCode {
13 VerificationFailed,
14 MissingResponse,
15 UnknownError,
16}
17
18impl CaptchaErrorCode {
19 pub fn as_str(self) -> &'static str {
20 match self {
21 Self::VerificationFailed => "VERIFICATION_FAILED",
22 Self::MissingResponse => "MISSING_RESPONSE",
23 Self::UnknownError => "UNKNOWN_ERROR",
24 }
25 }
26
27 pub fn message(self) -> &'static str {
28 match self {
29 Self::VerificationFailed => "Captcha verification failed",
30 Self::MissingResponse => "Missing CAPTCHA response",
31 Self::UnknownError => "Something went wrong",
32 }
33 }
34}