aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'filamento/src/error.rs')
-rw-r--r--filamento/src/error.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/filamento/src/error.rs b/filamento/src/error.rs
index 02f54ee..9334793 100644
--- a/filamento/src/error.rs
+++ b/filamento/src/error.rs
@@ -9,7 +9,10 @@ use thiserror::Error;
pub use lampada::error::CommandError;
pub use lampada::error::ConnectionError;
+use tokio::sync::mpsc::error::SendError;
+use tokio::sync::oneshot::error::RecvError;
+use crate::db::DbCommand;
use crate::files::FileStore;
// for the client logic impl
@@ -166,8 +169,20 @@ pub enum ResponseError {
}
#[derive(Debug, Error, Clone)]
-#[error("database error: {0}")]
-pub struct DatabaseError(pub Serializeable<Arc<rusqlite::Error>>);
+pub enum DatabaseError {
+ #[error("database error: {0}")]
+ Database(Serializeable<Arc<rusqlite::Error>>),
+ #[error("database command send: {0}")]
+ Send(Arc<SendError<DbCommand>>),
+ #[error("database result recv: {0}")]
+ Recv(#[from] RecvError),
+}
+
+impl From<SendError<DbCommand>> for DatabaseError {
+ fn from(e: SendError<DbCommand>) -> Self {
+ Self::Send(Arc::new(e))
+ }
+}
pub enum Serializeable<T> {
String(String),
@@ -227,7 +242,7 @@ impl<'de> serde::Deserialize<'de> for DatabaseError {
D: serde::Deserializer<'de>,
{
let string = deserializer.deserialize_string(StringVisitor)?;
- Ok(Self(Serializeable::String(string)))
+ Ok(Self::Database(Serializeable::String(string)))
}
}
@@ -246,7 +261,7 @@ impl serde::Serialize for DatabaseError {
impl From<rusqlite::Error> for DatabaseError {
fn from(e: rusqlite::Error) -> Self {
- Self(Serializeable::Unserialized(Arc::new(e)))
+ Self::Database(Serializeable::Unserialized(Arc::new(e)))
}
}
@@ -285,6 +300,8 @@ pub enum DatabaseOpenError {
Io(Arc<tokio::io::Error>),
#[error("invalid path")]
InvalidPath,
+ #[error("tokio oneshot recv error: {0}")]
+ Recv(#[from] tokio::sync::oneshot::error::RecvError),
}
// impl From<sqlx::migrate::MigrateError> for DatabaseOpenError {