mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Add custom error type to database module
This commit is contained in:
parent
5a41d5008f
commit
d7fb996183
11 changed files with 232 additions and 116 deletions
26
src/backend/database/error.rs
Normal file
26
src/backend/database/error.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use thiserror::Error;
|
||||
|
||||
/// Error that happens within the database module.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum DatabaseError {
|
||||
#[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.
|
||||
pub type DatabaseResult<T> = Result<T, DatabaseError>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue