1use thiserror::Error;
2
3use crate::api::ProviderKind;
4
5#[derive(Error, Debug)]
6pub enum AuthError {
7 #[error("Network error: {0}")]
8 Network(#[from] reqwest::Error),
9
10 #[error("Invalid authorization code")]
11 InvalidCode,
12
13 #[error("Storage error: {0}")]
14 Storage(String),
15
16 #[error("Token expired")]
17 Expired,
18
19 #[error("Re-authentication required")]
20 ReauthRequired,
21
22 #[error("OAuth flow cancelled by user")]
23 Cancelled,
24
25 #[error("Failed to start callback server: {0}")]
26 CallbackServer(String),
27
28 #[error("OAuth state mismatch")]
29 StateMismatch,
30
31 #[error("Invalid OAuth response: {0}")]
32 InvalidResponse(String),
33
34 #[error("Keyring error: {0}")]
35 Keyring(#[from] keyring::Error),
36
37 #[error("Encryption error: {0}")]
38 Encryption(String),
39
40 #[error("IO error: {0}")]
41 Io(#[from] std::io::Error),
42
43 #[error("Unsupported authentication method: {method} for provider {provider}")]
44 UnsupportedMethod {
45 method: String,
46 provider: ProviderKind,
47 },
48
49 #[error("Invalid authentication state: {0}")]
50 InvalidState(String),
51
52 #[error("Invalid credential: {0}")]
53 InvalidCredential(String),
54
55 #[error("Missing required input: {0}")]
56 MissingInput(String),
57}
58
59pub type Result<T> = std::result::Result<T, AuthError>;