use oxisql_core::OxiSqlError;
#[derive(Debug, thiserror::Error)]
pub enum SqliteCompatError {
#[error("limbo execution error: {0}")]
Limbo(String),
#[error("type mapping error: {0}")]
TypeMap(String),
#[error("connection error: {0}")]
Connection(String),
#[error("transaction already active — nested transactions are not supported")]
NestedTransaction,
#[error("schema introspection error: {0}")]
Schema(String),
#[error("{0}")]
Other(String),
}
impl From<limbo::Error> for SqliteCompatError {
fn from(e: limbo::Error) -> Self {
SqliteCompatError::Limbo(e.to_string())
}
}
impl From<SqliteCompatError> for OxiSqlError {
fn from(e: SqliteCompatError) -> Self {
match e {
SqliteCompatError::Limbo(msg) => OxiSqlError::Execution(msg),
SqliteCompatError::TypeMap(msg) => OxiSqlError::Other(msg),
SqliteCompatError::Connection(msg) => OxiSqlError::Other(msg),
SqliteCompatError::NestedTransaction => {
OxiSqlError::Other("nested transactions are not supported".into())
}
SqliteCompatError::Schema(msg) => OxiSqlError::Other(msg),
SqliteCompatError::Other(msg) => OxiSqlError::Other(msg),
}
}
}