musicus/database/src/error.rs

25 lines
699 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)]
ReceiveError(#[from] futures_channel::oneshot::Canceled),
#[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>;