Skip to main content

sql_stream/
error.rs

1//! Error types for the SQL Stream library
2//!
3//! This module defines all error types used throughout the library using `thiserror`
4//! for ergonomic error handling and proper error propagation.
5
6use std::path::PathBuf;
7use thiserror::Error;
8
9/// Main error type for SQL Stream operations
10#[derive(Error, Debug)]
11pub enum SqlStreamError {
12    /// File-related errors
13    #[error("File not found: {0}")]
14    FileNotFound(PathBuf),
15
16    /// Invalid file format or extension
17    #[error("Unsupported file format: {0}. Supported formats: .csv, .json")]
18    UnsupportedFormat(String),
19
20    /// DataFusion-related errors
21    #[error("DataFusion error: {0}")]
22    DataFusion(#[from] datafusion::error::DataFusionError),
23
24    /// Arrow-related errors
25    #[error("Arrow error: {0}")]
26    Arrow(#[from] arrow::error::ArrowError),
27
28    /// IO errors
29    #[error("IO error: {0}")]
30    Io(#[from] std::io::Error),
31
32    /// SQL execution errors
33    #[error("SQL execution failed: {0}")]
34    QueryExecution(String),
35
36    /// Table registration errors
37    #[error("Failed to register table '{0}': {1}")]
38    TableRegistration(String, String),
39
40    /// Schema inference errors
41    #[error("Failed to infer schema from file: {0}")]
42    SchemaInference(String),
43}
44
45/// Type alias for Results using SqlStreamError
46pub type Result<T> = std::result::Result<T, SqlStreamError>;