diff options
Diffstat (limited to 'server/src/ui/error.rs')
| -rw-r--r-- | server/src/ui/error.rs | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/server/src/ui/error.rs b/server/src/ui/error.rs index 0f279fc..578d841 100644 --- a/server/src/ui/error.rs +++ b/server/src/ui/error.rs @@ -3,38 +3,20 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2026 metamuffin <metamuffin.org> */ -use log::info; use rocket::{ - catch, - http::{ContentType, Status}, - response::{self, content::RawHtml, Responder}, - Request, + Request, catch, + http::Status, + response::{self, Responder, content::RawHtml}, }; -use serde_json::{json, Value}; -use std::{fmt::Display, fs::File, io::Read, sync::LazyLock}; - -static ERROR_IMAGE: LazyLock<Vec<u8>> = LazyLock::new(|| { - info!("loading error image"); - let mut f = File::open(CONF.asset_path.join("error.avif")) - .expect("please create error.avif in the asset dir"); - let mut o = Vec::new(); - f.read_to_end(&mut o).unwrap(); - o -}); +use serde_json::{Value, json}; +use std::fmt::Display; #[catch(default)] pub fn r_catch(status: Status, _request: &Request) -> RawHtml<String> { catch_with_message(format!("{status}")) } fn catch_with_message(message: String) -> RawHtml<String> { - RawHtml(render_page( - &ErrorPage { status: message }, - RenderInfo { - importing: false, - session: None, - lang: Language::English, - }, - )) + RawHtml(message) // TODO } #[catch(default)] @@ -52,9 +34,9 @@ impl<'r> Responder<'r, 'static> for MyError { fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> { match req.accept().map(|a| a.preferred()) { Some(x) if x.is_json() => json!({ "error": format!("{}", self.0) }).respond_to(req), - Some(x) if x.is_avif() || x.is_png() || x.is_jpeg() => { - (ContentType::AVIF, ERROR_IMAGE.as_slice()).respond_to(req) - } + // Some(x) if x.is_avif() || x.is_png() || x.is_jpeg() => { + // (ContentType::AVIF, ERROR_IMAGE.as_slice()).respond_to(req) + // } _ => catch_with_message(format!("{:#}", self.0)).respond_to(req), } } |