Add AppState, DB and Snafu

This commit is contained in:
gabatxo1312 2026-01-26 01:05:10 +01:00
commit a3c0b194e1
11 changed files with 2512 additions and 143 deletions

30
src/state/error.rs Normal file
View file

@ -0,0 +1,30 @@
use askama::Template;
use askama_web::WebTemplate;
use axum::response::{IntoResponse, Response};
use snafu::prelude::*;
use crate::state::config::ConfigError;
#[derive(Template, WebTemplate)]
#[template(path = "error.html")]
struct ErrorTemplate {}
#[derive(Snafu, Debug)]
#[snafu(visibility(pub))]
pub enum AppStateError {
Error,
#[snafu(display("Sqlite Error"))]
Sqlite {
source: sea_orm::error::DbErr,
},
#[snafu(display("Config Error"))]
ConfigError {
source: ConfigError,
},
}
impl IntoResponse for AppStateError {
fn into_response(self) -> Response {
ErrorTemplate {}.into_response()
}
}