Skip to main content

oxigdal_cloud_enhanced/
error.rs

1//! Error types for cloud-enhanced operations.
2
3/// Result type alias for cloud-enhanced operations.
4pub type Result<T> = std::result::Result<T, CloudEnhancedError>;
5
6/// Errors that can occur during cloud-enhanced operations.
7#[derive(Debug, thiserror::Error)]
8pub enum CloudEnhancedError {
9    /// AWS service error
10    #[error("AWS service error: {0}")]
11    AwsService(String),
12
13    /// Azure service error
14    #[error("Azure service error: {0}")]
15    AzureService(String),
16
17    /// GCP service error
18    #[error("GCP service error: {0}")]
19    GcpService(String),
20
21    /// Authentication error
22    #[error("Authentication error: {0}")]
23    Authentication(String),
24
25    /// Query execution error
26    #[error("Query execution error: {0}")]
27    QueryExecution(String),
28
29    /// Data catalog error
30    #[error("Data catalog error: {0}")]
31    DataCatalog(String),
32
33    /// ML service error
34    #[error("ML service error: {0}")]
35    MlService(String),
36
37    /// Monitoring error
38    #[error("Monitoring error: {0}")]
39    Monitoring(String),
40
41    /// Cost optimization error
42    #[error("Cost optimization error: {0}")]
43    CostOptimization(String),
44
45    /// Configuration error
46    #[error("Configuration error: {0}")]
47    Configuration(String),
48
49    /// Serialization error
50    #[error("Serialization error: {0}")]
51    Serialization(String),
52
53    /// IO error
54    #[error("IO error: {0}")]
55    Io(#[from] std::io::Error),
56
57    /// Arrow error
58    #[error("Arrow error: {0}")]
59    Arrow(String),
60
61    /// Parquet error
62    #[error("Parquet error: {0}")]
63    Parquet(String),
64
65    /// Invalid state
66    #[error("Invalid state: {0}")]
67    InvalidState(String),
68
69    /// Timeout error
70    #[error("Operation timed out: {0}")]
71    Timeout(String),
72
73    /// Not found error
74    #[error("Resource not found: {0}")]
75    NotFound(String),
76
77    /// Permission denied
78    #[error("Permission denied: {0}")]
79    PermissionDenied(String),
80
81    /// Quota exceeded
82    #[error("Quota exceeded: {0}")]
83    QuotaExceeded(String),
84
85    /// Invalid argument
86    #[error("Invalid argument: {0}")]
87    InvalidArgument(String),
88
89    /// Generic error
90    #[error("{0}")]
91    Generic(String),
92}
93
94impl CloudEnhancedError {
95    /// Creates a new AWS service error.
96    pub fn aws_service(msg: impl Into<String>) -> Self {
97        Self::AwsService(msg.into())
98    }
99
100    /// Creates a new Azure service error.
101    pub fn azure_service(msg: impl Into<String>) -> Self {
102        Self::AzureService(msg.into())
103    }
104
105    /// Creates a new GCP service error.
106    pub fn gcp_service(msg: impl Into<String>) -> Self {
107        Self::GcpService(msg.into())
108    }
109
110    /// Creates a new authentication error.
111    pub fn authentication(msg: impl Into<String>) -> Self {
112        Self::Authentication(msg.into())
113    }
114
115    /// Creates a new query execution error.
116    pub fn query_execution(msg: impl Into<String>) -> Self {
117        Self::QueryExecution(msg.into())
118    }
119
120    /// Creates a new data catalog error.
121    pub fn data_catalog(msg: impl Into<String>) -> Self {
122        Self::DataCatalog(msg.into())
123    }
124
125    /// Creates a new ML service error.
126    pub fn ml_service(msg: impl Into<String>) -> Self {
127        Self::MlService(msg.into())
128    }
129
130    /// Creates a new monitoring error.
131    pub fn monitoring(msg: impl Into<String>) -> Self {
132        Self::Monitoring(msg.into())
133    }
134
135    /// Creates a new cost optimization error.
136    pub fn cost_optimization(msg: impl Into<String>) -> Self {
137        Self::CostOptimization(msg.into())
138    }
139
140    /// Creates a new configuration error.
141    pub fn configuration(msg: impl Into<String>) -> Self {
142        Self::Configuration(msg.into())
143    }
144
145    /// Creates a new serialization error.
146    pub fn serialization(msg: impl Into<String>) -> Self {
147        Self::Serialization(msg.into())
148    }
149
150    /// Creates a new Arrow error.
151    pub fn arrow(msg: impl Into<String>) -> Self {
152        Self::Arrow(msg.into())
153    }
154
155    /// Creates a new Parquet error.
156    pub fn parquet(msg: impl Into<String>) -> Self {
157        Self::Parquet(msg.into())
158    }
159
160    /// Creates a new invalid state error.
161    pub fn invalid_state(msg: impl Into<String>) -> Self {
162        Self::InvalidState(msg.into())
163    }
164
165    /// Creates a new timeout error.
166    pub fn timeout(msg: impl Into<String>) -> Self {
167        Self::Timeout(msg.into())
168    }
169
170    /// Creates a new not found error.
171    pub fn not_found(msg: impl Into<String>) -> Self {
172        Self::NotFound(msg.into())
173    }
174
175    /// Creates a new permission denied error.
176    pub fn permission_denied(msg: impl Into<String>) -> Self {
177        Self::PermissionDenied(msg.into())
178    }
179
180    /// Creates a new quota exceeded error.
181    pub fn quota_exceeded(msg: impl Into<String>) -> Self {
182        Self::QuotaExceeded(msg.into())
183    }
184
185    /// Creates a new invalid argument error.
186    pub fn invalid_argument(msg: impl Into<String>) -> Self {
187        Self::InvalidArgument(msg.into())
188    }
189
190    /// Creates a new generic error.
191    pub fn generic(msg: impl Into<String>) -> Self {
192        Self::Generic(msg.into())
193    }
194}
195
196impl From<serde_json::Error> for CloudEnhancedError {
197    fn from(err: serde_json::Error) -> Self {
198        Self::serialization(err.to_string())
199    }
200}
201
202impl From<arrow::error::ArrowError> for CloudEnhancedError {
203    fn from(err: arrow::error::ArrowError) -> Self {
204        Self::arrow(err.to_string())
205    }
206}
207
208impl From<parquet::errors::ParquetError> for CloudEnhancedError {
209    fn from(err: parquet::errors::ParquetError) -> Self {
210        Self::parquet(err.to_string())
211    }
212}