use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[doc(hidden)]
#[error("Conditional clause is not truthy")]
Ignore,
#[error("Database instance is not initialized")]
DbNotInitialized,
#[error("There was a problem with the underlying datastore: {0}")]
Ds(String),
#[error("No column family found in this datastore")]
DsNoColumnFamilyFound,
#[error("Column family is not valid")]
DsColumnFamilyIsNotValid,
#[error("There was a problem with a datastore transaction: {0}")]
Tx(String),
#[error("There was an error when starting a new datastore transaction")]
TxFailure,
#[error("Couldn't update a finished transaction")]
TxFinished,
#[error("Couldn't write to a read only transaction")]
TxReadonly,
#[error("Value being checked was not correct")]
TxConditionNotMet,
#[error("The key is not in the database")]
TxnKeyNotFound,
#[error("The key being inserted already exists")]
TxKeyAlreadyExists,
#[error("Cannot convert from '{0}' to '{1}'")]
TryFromError(String, &'static str),
}
#[cfg(feature = "kv-rocksdb")]
impl From<rocksdb::Error> for Error {
fn from(e: rocksdb::Error) -> Error {
Error::Tx(e.to_string())
}
}
#[cfg(feature = "kv-redb")]
impl From<redb::Error> for Error {
fn from(e: redb::Error) -> Error {
Error::Tx(e.to_string())
}
}
#[cfg(feature = "kv-sled")]
impl From<sled::Error> for Error {
fn from(e: sled::Error) -> Error {
Error::Tx(e.to_string())
}
}