kraken_auth/
error.rs

1//! Error types for authentication operations
2
3/// Errors that can occur during authentication
4#[derive(Debug, thiserror::Error)]
5pub enum AuthError {
6    /// HTTP request failed
7    #[error("HTTP error: {0}")]
8    Http(#[from] reqwest::Error),
9
10    /// Invalid API credentials
11    #[error("Invalid credentials: {0}")]
12    InvalidCredentials(String),
13
14    /// API returned an error
15    #[error("API error: {0}")]
16    Api(String),
17
18    /// Failed to parse response
19    #[error("Parse error: {0}")]
20    Parse(String),
21
22    /// Environment variable not set
23    #[error("Environment variable not set: {0}")]
24    EnvVarNotSet(String),
25
26    /// Token expired
27    #[error("WebSocket token expired")]
28    TokenExpired,
29}
30
31/// Result type for authentication operations
32pub type AuthResult<T> = Result<T, AuthError>;
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37
38    #[test]
39    fn test_error_display() {
40        let err = AuthError::EnvVarNotSet("KRAKEN_API_KEY".to_string());
41        assert!(err.to_string().contains("KRAKEN_API_KEY"));
42    }
43}