session revoking, perm, DatabaseError (partially)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user