2026-04-13 07:48:27 +00:00
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
|
pub struct AppError {
|
|
|
|
|
pub message: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<rusqlite::Error> for AppError {
|
|
|
|
|
fn from(e: rusqlite::Error) -> Self {
|
|
|
|
|
AppError {
|
|
|
|
|
message: e.to_string(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<std::io::Error> for AppError {
|
|
|
|
|
fn from(e: std::io::Error) -> Self {
|
|
|
|
|
AppError {
|
|
|
|
|
message: e.to_string(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<String> for AppError {
|
|
|
|
|
fn from(s: String) -> Self {
|
|
|
|
|
AppError { message: s }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 12:20:45 +00:00
|
|
|
impl From<reqwest::Error> for AppError {
|
|
|
|
|
fn from(e: reqwest::Error) -> Self {
|
|
|
|
|
AppError { message: e.to_string() }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 07:48:27 +00:00
|
|
|
impl std::fmt::Display for AppError {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
write!(f, "{}", self.message)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-13 08:16:44 +00:00
|
|
|
|
|
|
|
|
impl std::error::Error for AppError {}
|