Skip to main content

vortex_sdk/
error.rs

1use std::fmt;
2
3/// Error types for Vortex SDK operations
4#[derive(Debug)]
5pub enum VortexError {
6    /// Invalid API key format or content
7    InvalidApiKey(String),
8    /// Cryptographic operation failed
9    CryptoError(String),
10    /// HTTP request failed
11    HttpError(String),
12    /// API returned an error
13    ApiError(String),
14    /// JSON serialization/deserialization failed
15    SerializationError(String),
16    /// Invalid request
17    InvalidRequest(String),
18    /// Webhook signature verification failed
19    WebhookSignatureError(String),
20}
21
22impl fmt::Display for VortexError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            VortexError::InvalidApiKey(msg) => write!(f, "Invalid API key: {}", msg),
26            VortexError::CryptoError(msg) => write!(f, "Crypto error: {}", msg),
27            VortexError::HttpError(msg) => write!(f, "HTTP error: {}", msg),
28            VortexError::ApiError(msg) => write!(f, "API error: {}", msg),
29            VortexError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
30            VortexError::InvalidRequest(msg) => write!(f, "Invalid request: {}", msg),
31            VortexError::WebhookSignatureError(msg) => write!(f, "Webhook signature error: {}", msg),
32        }
33    }
34}
35
36impl std::error::Error for VortexError {}