From f62c7f2a8cc143454779dc99334ca9fc80ddabd5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 29 Apr 2025 11:10:21 +0200 Subject: still just moving code around --- server/src/ui/error.rs | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'server/src/ui/error.rs') diff --git a/server/src/ui/error.rs b/server/src/ui/error.rs index 6ba2ba9..0ea1a8d 100644 --- a/server/src/ui/error.rs +++ b/server/src/ui/error.rs @@ -8,7 +8,7 @@ use log::info; use rocket::{ catch, http::{ContentType, Status}, - response::{self, Responder}, + response::{self, content::RawHtml, Responder}, Request, }; use serde_json::{json, Value}; @@ -24,18 +24,19 @@ static ERROR_IMAGE: LazyLock> = LazyLock::new(|| { }); #[catch(default)] -pub fn r_catch<'a>(status: Status, _request: &Request) -> DynLayoutPage<'a> { - LayoutPage { - title: "Not found".to_string(), - content: markup::new! { - h2 { "Error" } - p { @format!("{status}") } - @if status == Status::NotFound { - p { "You might need to " a[href=uri!(r_account_login())] { "log in" } ", to see this page" } - } - }, - ..Default::default() - } +pub fn r_catch<'a>(status: Status, _request: &Request) -> RawHtml { + // LayoutPage { + // title: "Not found".to_string(), + // content: markup::new! { + // h2 { "Error" } + // p { @format!("{status}") } + // @if status == Status::NotFound { + // p { "You might need to " a[href=uri!(r_account_login())] { "log in" } ", to see this page" } + // } + // }, + // ..Default::default() + // } + RawHtml("as".to_string()) } #[catch(default)] @@ -56,15 +57,7 @@ impl<'r> Responder<'r, 'static> for MyError { Some(x) if x.is_avif() || x.is_png() || x.is_jpeg() => { (ContentType::AVIF, ERROR_IMAGE.as_slice()).respond_to(req) } - _ => LayoutPage { - title: "Error".to_string(), - content: markup::new! { - h2 { "An error occured. Nobody is sorry"} - pre.error { @format!("{:?}", self.0) } - }, - ..Default::default() - } - .respond_to(req), + _ => r_catch(Status::InternalServerError, req).respond_to(req), } } } -- cgit v1.2.3-70-g09d2