23 lines
484 B
Rust
23 lines
484 B
Rust
|
|
use thiserror::Error;
|
||
|
|
|
||
|
|
#[derive(Error, Debug)]
|
||
|
|
pub enum DatabaseError {
|
||
|
|
#[error("SQLite error: {0}")]
|
||
|
|
Sqlite(#[from] rusqlite::Error),
|
||
|
|
|
||
|
|
#[error("Record not found: {0}")]
|
||
|
|
NotFound(String),
|
||
|
|
|
||
|
|
#[error("Invalid data: {0}")]
|
||
|
|
InvalidData(String),
|
||
|
|
}
|
||
|
|
|
||
|
|
impl serde::Serialize for DatabaseError {
|
||
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||
|
|
where
|
||
|
|
S: serde::Serializer,
|
||
|
|
{
|
||
|
|
serializer.serialize_str(&self.to_string())
|
||
|
|
}
|
||
|
|
}
|