session revoking, perm, DatabaseError (partially)

This commit is contained in:
2026-02-28 23:27:56 +01:00
parent 94dcc1816d
commit c8d15f8c6b
4 changed files with 45 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
use std::{env, error::Error, sync::LazyLock};
use axum::{http::StatusCode, response::IntoResponse};
use rusqlite::{Connection, OptionalExtension};
macro_rules! migration {
@@ -21,6 +22,16 @@ CREATE TABLE IF NOT EXISTS migrations (
);
"#;
#[derive(Debug, thiserror::Error)]
#[error("{0}")]
pub struct DatabaseError(#[from] rusqlite::Error);
impl IntoResponse for DatabaseError {
fn into_response(self) -> axum::response::Response {
println!("[DB ERROR] {}", self.to_string());
(StatusCode::INTERNAL_SERVER_ERROR, "Internal server error.").into_response()
}
}
pub fn conn() -> Result<Connection, rusqlite::Error> {
let conn = Connection::open(&*DB_URL)?;
for pragma in CONNECTION_PRAGMAS {