use thiserror::Error;
pub type Result<T> = std::result::Result<T, RayforceError>;
#[derive(Error, Debug)]
pub enum RayforceError {
#[error("Failed to create runtime")]
RuntimeCreationFailed,
#[error("Evaluation failed: {0}")]
EvalFailed(String),
#[error("Type mismatch: expected {expected}, got {actual}")]
TypeMismatch {
expected: String,
actual: String,
},
#[error("Index out of bounds: {index} (length: {length})")]
IndexOutOfBounds {
index: i64,
length: i64,
},
#[error("Null pointer encountered")]
NullPointer,
#[error("Invalid string encoding")]
InvalidString,
#[error("Key not found: {0}")]
KeyNotFound(String),
#[error("Cannot perform destructive operation on parted table: {0}")]
PartedTableError(String),
#[error("Connection error: {0}")]
ConnectionError(String),
#[error("IO error: {0}")]
IoError(String),
#[error("Query error: {0}")]
QueryError(String),
#[error("Conversion error: {0}")]
ConversionError(String),
#[error("Memory allocation failed")]
AllocationFailed,
#[error("Invalid GUID format: {0}")]
InvalidGuid(String),
#[error("C API error: {0}")]
CApiError(String),
}
impl From<std::ffi::NulError> for RayforceError {
fn from(_: std::ffi::NulError) -> Self {
RayforceError::InvalidString
}
}
impl From<std::str::Utf8Error> for RayforceError {
fn from(_: std::str::Utf8Error) -> Self {
RayforceError::InvalidString
}
}