feat: move core services to services directory
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
8cc0cfc606
commit
321e00171e
37
src/services/error.rs
Normal file
37
src/services/error.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum CoreError {
|
||||
#[error("Database error: {0}")]
|
||||
Database(#[from] rusqlite::Error),
|
||||
|
||||
#[error("I/O error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
#[error("Item not found with id {0}")]
|
||||
ItemNotFound(i64),
|
||||
|
||||
#[error("Item not found")]
|
||||
ItemNotFoundGeneric,
|
||||
|
||||
#[error("Invalid input: {0}")]
|
||||
InvalidInput(String),
|
||||
|
||||
#[error("Configuration error: {0}")]
|
||||
Config(String),
|
||||
|
||||
#[error("Compression error: {0}")]
|
||||
Compression(String),
|
||||
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
impl From<rusqlite_migration::Error> for CoreError {
|
||||
fn from(err: rusqlite_migration::Error) -> Self {
|
||||
match err {
|
||||
rusqlite_migration::Error::RusqliteError { err: e, .. } => CoreError::Database(e),
|
||||
e => CoreError::Other(e.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user