1use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6 #[doc(hidden)]
8 #[error("Conditional clause is not truthy")]
9 Ignore,
10
11 #[error("Database instance is not initialized")]
12 DbNotInitialized,
13
14 #[error("There was a problem with the underlying datastore: {0}")]
16 Ds(String),
17
18 #[error("No column family found in this datastore")]
19 DsNoColumnFamilyFound,
20
21 #[error("Column family is not valid")]
22 DsColumnFamilyIsNotValid,
23
24 #[error("There was a problem with a datastore transaction: {0}")]
26 Tx(String),
27
28 #[error("There was an error when starting a new datastore transaction")]
30 TxFailure,
31
32 #[error("Couldn't update a finished transaction")]
34 TxFinished,
35
36 #[error("Couldn't write to a read only transaction")]
38 TxReadonly,
39
40 #[error("Value being checked was not correct")]
42 TxConditionNotMet,
43
44 #[error("The key is not in the database")]
46 TxnKeyNotFound,
47
48 #[error("The key being inserted already exists")]
50 TxKeyAlreadyExists,
51
52 #[error("Cannot convert from '{0}' to '{1}'")]
54 TryFromError(String, &'static str),
55}
56
57#[cfg(feature = "kv-rocksdb")]
58impl From<rocksdb::Error> for Error {
59 fn from(e: rocksdb::Error) -> Error {
60 Error::Tx(e.to_string())
61 }
62}
63
64#[cfg(feature = "kv-redb")]
65impl From<redb::Error> for Error {
66 fn from(e: redb::Error) -> Error {
67 Error::Tx(e.to_string())
68 }
69}
70
71#[cfg(feature = "kv-sled")]
72impl From<sled::Error> for Error {
73 fn from(e: sled::Error) -> Error {
74 Error::Tx(e.to_string())
75 }
76}