musicus/database/src/error.rs

25 lines
703 B
Rust
Raw Normal View History

/// Error that happens within the database module.
2021-02-04 21:47:22 +01:00
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
ConnectionError(#[from] diesel::result::ConnectionError),
#[error(transparent)]
MigrationsError(#[from] diesel_migrations::RunMigrationsError),
#[error(transparent)]
QueryError(#[from] diesel::result::Error),
#[error(transparent)]
SendError(#[from] std::sync::mpsc::SendError<super::thread::Action>),
#[error(transparent)]
2021-04-25 22:33:40 +02:00
ReceiveError(#[from] tokio::sync::oneshot::error::RecvError),
#[error("Database error: {0}")]
Other(String),
}
/// Return type for database methods.
2021-02-04 21:47:22 +01:00
pub type Result<T> = std::result::Result<T, Error>;