musicus/database/src/error.rs

28 lines
825 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),
2021-04-25 22:48:25 +02:00
#[error("Missing item dependency ({0} {1})")]
MissingItem(&'static str, String),
2021-04-25 22:56:16 +02:00
#[error("Failed to parse {0} from '{1}'")]
ParsingError(&'static str, String),
#[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),
}
/// Return type for database methods.
2021-02-04 21:47:22 +01:00
pub type Result<T> = std::result::Result<T, Error>;