Add AppState, DB and Snafu
This commit is contained in:
parent
e8529bdbee
commit
a3c0b194e1
11 changed files with 2512 additions and 143 deletions
30
src/state/error.rs
Normal file
30
src/state/error.rs
Normal 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()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue