db/err/
mod.rs

1/// Error
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6	/// This error is used for ignoring a document when processing a query
7	#[doc(hidden)]
8	#[error("Conditional clause is not truthy")]
9	Ignore,
10
11	#[error("Database instance is not initialized")]
12	DbNotInitialized,
13
14	/// There was a problem with the underlying datastore
15	#[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	/// There was a problem with a datastore transaction
25	#[error("There was a problem with a datastore transaction: {0}")]
26	Tx(String),
27
28	/// There was an error when starting a new datastore transaction
29	#[error("There was an error when starting a new datastore transaction")]
30	TxFailure,
31
32	/// The transaction was already cancelled or committed
33	#[error("Couldn't update a finished transaction")]
34	TxFinished,
35
36	/// The current transaction was created as read-only
37	#[error("Couldn't write to a read only transaction")]
38	TxReadonly,
39
40	/// The conditional value in the request was not equal
41	#[error("Value being checked was not correct")]
42	TxConditionNotMet,
43
44	/// The key being mutated is not in the database
45	#[error("The key is not in the database")]
46	TxnKeyNotFound,
47
48	/// The key being inserted in the transaction already exists
49	#[error("The key being inserted already exists")]
50	TxKeyAlreadyExists,
51
52	/// It's is not possible to convert between the two types
53	#[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}