1use std::sync::Arc;
2use thiserror::Error;
3
4#[derive(Debug, Clone, Error)]
5pub enum OAuthError {
6 #[error("User cancelled authorization")]
7 UserCancelled,
8
9 #[error("OAuth credential storage error: {0}")]
10 CredentialStore(String),
11
12 #[error("IO error: {0}")]
13 Io(Arc<std::io::Error>),
14
15 #[error("Invalid OAuth callback: {0}")]
16 InvalidCallback(String),
17
18 #[error("Token exchange failed: {0}")]
19 TokenExchange(String),
20
21 #[error("OAuth state mismatch — possible CSRF attack")]
22 StateMismatch,
23
24 #[error("No credentials found: {0}")]
25 NoCredentials(String),
26}
27
28impl From<std::io::Error> for OAuthError {
29 fn from(error: std::io::Error) -> Self {
30 Self::Io(Arc::new(error))
31 }
32}