File size: 762 Bytes
0f6a233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! SAIL Kernel Error Types
//!
//! Centralized, typed errors for all kernel operations.
//! Uses `thiserror` for ergonomic, zero-cost error handling with no `unwrap`.

use thiserror::Error;

/// All possible errors in the SAIL kernel
#[derive(Error, Debug)]
pub enum KernelError {
    #[error("I/O error: {0}")]
    IoError(String),

    #[error("Arrow write error: {0}")]
    ArrowError(String),

    #[error("Compression error: {0}")]
    CompressionError(String),

    #[error("Tokenizer error: {0}")]
    TokenizerError(String),

    #[error("Invalid input: {0}")]
    InvalidInput(String),
}

impl From<KernelError> for pyo3::PyErr {
    fn from(err: KernelError) -> pyo3::PyErr {
        pyo3::exceptions::PyRuntimeError::new_err(err.to_string())
    }
}