diff options
author | metamuffin <metamuffin@disroot.org> | 2023-01-22 13:56:06 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-01-22 13:56:06 +0100 |
commit | ec76bbe5398f51ffa55bfd315b30c0a07245d4e6 (patch) | |
tree | fa0e1723f861de6fee21a35524bb7768fab0b6ce /server/src/routes/ui/error.rs | |
parent | 84e093afa908dc68a7b0ae97ba8dc76aa0901d26 (diff) | |
download | jellything-ec76bbe5398f51ffa55bfd315b30c0a07245d4e6.tar jellything-ec76bbe5398f51ffa55bfd315b30c0a07245d4e6.tar.bz2 jellything-ec76bbe5398f51ffa55bfd315b30c0a07245d4e6.tar.zst |
this is *horrible*
Diffstat (limited to 'server/src/routes/ui/error.rs')
-rw-r--r-- | server/src/routes/ui/error.rs | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/server/src/routes/ui/error.rs b/server/src/routes/ui/error.rs index 1a50796..011847e 100644 --- a/server/src/routes/ui/error.rs +++ b/server/src/routes/ui/error.rs @@ -1,6 +1,9 @@ +use super::layout::LayoutPage; use super::{layout::Layout, HtmlTemplate}; +use crate::routes::ui::account::rocket_uri_macro_r_account_login; use markup::Render; use rocket::http::Status; +use rocket::uri; use rocket::{ catch, http::ContentType, @@ -10,37 +13,44 @@ use rocket::{ use std::{fmt::Display, io::Cursor}; #[catch(default)] -pub fn r_not_found<'a>(status: Status, _request: &Request) -> HtmlTemplate<markup::DynRender<'a>> { - HtmlTemplate( - "Not found".to_string(), - markup::new! { - h2 { "Error" } - p { @format!("{status:?}") } - }, - ) +pub fn r_catch<'a>(status: Status, _request: &Request) -> () { + // HtmlTemplate(box Layout { + // title: "Not found".to_string(), + // session: None, + // main: markup::new! { + // h2 { "Error" } + // p { @format!("{status}") } + // @if status == Status::NotFound { + // p { "You might need to " a[href=&uri!(r_account_login()).to_string()] { "log in" } ", to see this page" } + // } + // }, + // }) + todo!() } pub type MyResult<T> = Result<T, MyError>; #[derive(Debug)] -pub struct MyError(anyhow::Error); +pub struct MyError(pub anyhow::Error); impl<'r> Responder<'r, 'static> for MyError { fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> { - let mut out = String::new(); - Layout { - title: "Error".to_string(), - main: markup::new! { - h2 { "An error occured. Nobody is sorry"} - pre.error { @format!("{:?}", self.0) } - }, - } - .render(&mut out) - .unwrap(); - Response::build() - .header(ContentType::HTML) - .streamed_body(Cursor::new(out)) - .ok() + // let mut out = String::new(); + // LayoutPage { + // title: "Error".to_string(), + // content: markup::new! { + // h2 { "An error occured. Nobody is sorry"} + // pre.error { @format!("{:?}", self.0) } + // }, + // } + // .render(&mut out) + // .unwrap(); + // Response::build() + // .header(ContentType::HTML) + // .status(Status::BadRequest) + // .streamed_body(Cursor::new(out)) + // .ok() + todo!() } } @@ -64,3 +74,8 @@ impl From<std::io::Error> for MyError { MyError(anyhow::anyhow!("{err}")) } } +impl From<sled::Error> for MyError { + fn from(err: sled::Error) -> Self { + MyError(anyhow::anyhow!("{err}")) + } +} |