Add original database code

This commit is contained in:
Elias Projahn 2023-09-30 18:26:11 +02:00
parent 08be3cb613
commit 7eacfe21f4
26 changed files with 2059 additions and 24 deletions

24
src/db/error.rs Normal file
View file

@ -0,0 +1,24 @@
/// Error that happens within the database module.
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Connection(#[from] diesel::result::ConnectionError),
#[error(transparent)]
Migrations(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error(transparent)]
Query(#[from] diesel::result::Error),
#[error("Missing item dependency ({0} {1})")]
MissingItem(&'static str, String),
#[error("Failed to parse {0} from '{1}'")]
Parsing(&'static str, String),
#[error("{0}")]
Other(&'static str),
}
/// Return type for database methods.
pub type Result<T> = std::result::Result<T, Error>;