2026-01-23 13:56:30 +01:00
|
|
|
use askama::Template;
|
|
|
|
|
use askama_web::WebTemplate;
|
|
|
|
|
use axum::response::{IntoResponse, Response};
|
2026-01-26 01:05:10 +01:00
|
|
|
use snafu::prelude::*;
|
|
|
|
|
|
2026-01-28 00:38:24 +01:00
|
|
|
use crate::{
|
|
|
|
|
models::{book::BookError, user::UserError},
|
|
|
|
|
state::config::ConfigError,
|
|
|
|
|
};
|
2026-01-23 13:56:30 +01:00
|
|
|
|
|
|
|
|
#[derive(Template, WebTemplate)]
|
|
|
|
|
#[template(path = "error.html")]
|
|
|
|
|
struct ErrorTemplate {}
|
|
|
|
|
|
2026-01-26 01:05:10 +01:00
|
|
|
#[derive(Snafu, Debug)]
|
|
|
|
|
#[snafu(visibility(pub))]
|
2026-01-23 13:56:30 +01:00
|
|
|
pub enum AppStateError {
|
|
|
|
|
Error,
|
2026-01-26 01:05:10 +01:00
|
|
|
#[snafu(display("Sqlite Error"))]
|
|
|
|
|
Sqlite {
|
|
|
|
|
source: sea_orm::error::DbErr,
|
|
|
|
|
},
|
|
|
|
|
#[snafu(display("Config Error"))]
|
|
|
|
|
ConfigError {
|
|
|
|
|
source: ConfigError,
|
|
|
|
|
},
|
2026-01-27 01:33:21 +01:00
|
|
|
#[snafu(display("Migration Error"))]
|
|
|
|
|
Migration {
|
|
|
|
|
source: sea_orm::error::DbErr,
|
|
|
|
|
},
|
|
|
|
|
#[snafu(display("User Model Error"))]
|
|
|
|
|
User {
|
|
|
|
|
source: UserError,
|
|
|
|
|
},
|
2026-01-28 00:38:24 +01:00
|
|
|
#[snafu(display("Book Model Error"))]
|
|
|
|
|
Book {
|
|
|
|
|
source: BookError,
|
|
|
|
|
},
|
2026-01-23 13:56:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl IntoResponse for AppStateError {
|
|
|
|
|
fn into_response(self) -> Response {
|
|
|
|
|
ErrorTemplate {}.into_response()
|
|
|
|
|
}
|
|
|
|
|
}
|