feat: add new error type for nested transaction
This commit is contained in:
parent
877b312b34
commit
ff24f783fe
4 changed files with 12 additions and 5 deletions
|
@ -97,7 +97,7 @@ impl<'me> ConnectionClient for Transaction<'me> {
|
|||
self.0
|
||||
.transaction()
|
||||
.await
|
||||
.map_err(|_| crate::Error::UpgradeToTransaction)
|
||||
.map_err(|_| crate::Error::UpgradeToNestedTransaction)
|
||||
.map(Transaction)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ pub enum Error {
|
|||
/// Returns if we cannot upgrade connection to transaction.
|
||||
#[cfg(feature = "nightly")]
|
||||
UpgradeToTransaction,
|
||||
/// Returns if we cannot upgrade transaction to a nested one.
|
||||
#[cfg(feature = "nightly")]
|
||||
UpgradeToNestedTransaction,
|
||||
/// Returns if we cannot commit transaction.
|
||||
#[cfg(feature = "nightly")]
|
||||
CommitTransaction,
|
||||
|
@ -42,6 +45,10 @@ impl fmt::Display for Error {
|
|||
#[cfg(feature = "nightly")]
|
||||
Error::UpgradeToTransaction => f.write_str("Cannot upgrade connection to transaction"),
|
||||
#[cfg(feature = "nightly")]
|
||||
Error::UpgradeToNestedTransaction => {
|
||||
f.write_str("Cannot upgrade transaction to a nested one")
|
||||
}
|
||||
#[cfg(feature = "nightly")]
|
||||
Error::CommitTransaction => f.write_str("Cannot commit changes of transaction"),
|
||||
#[cfg(feature = "nightly")]
|
||||
Error::RollbackTransaction => f.write_str("Cannot rolls transaction back"),
|
||||
|
|
|
@ -91,7 +91,7 @@ impl<'me> ConnectionClient for Transaction<'me> {
|
|||
fn start_transaction(&mut self) -> crate::Result<Self::Trx<'_>> {
|
||||
self.0
|
||||
.transaction()
|
||||
.map_err(|_| crate::Error::UpgradeToTransaction)
|
||||
.map_err(|_| crate::Error::UpgradeToNestedTransaction)
|
||||
.map(Transaction)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,9 +76,9 @@ impl<'me> ConnectionClient for Transaction<'me> {
|
|||
#[cfg(feature = "nightly")]
|
||||
fn start_transaction(&mut self) -> crate::Result<Self::Trx<'_>> {
|
||||
// At the moment we cannot implement nested transaction because
|
||||
// the transaction in `rusqlite` requires DerefMut, which cannot be
|
||||
// implemented yet 😣
|
||||
unimplemented!()
|
||||
// the transaction in `rusqlite` 😣 We need to implement
|
||||
// our box for transaction if we want to use it here.
|
||||
Err(crate::Error::UpgradeToNestedTransaction)
|
||||
// self.0
|
||||
// .transaction()
|
||||
// .map_err(|_| error::PersistenceError::UpgradeToTransaction)
|
||||
|
|
Reference in a new issue