aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/error.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-01-22 14:10:15 +0100
committermetamuffin <metamuffin@disroot.org>2023-01-22 14:10:15 +0100
commited870d1fc04891e79ab1d40be473a07810a62e69 (patch)
tree9955a00484b3311dfd4ea8121b7b4bb3654c0f86 /server/src/routes/ui/error.rs
parentec76bbe5398f51ffa55bfd315b30c0a07245d4e6 (diff)
downloadjellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar
jellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar.bz2
jellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar.zst
clean again
Diffstat (limited to 'server/src/routes/ui/error.rs')
-rw-r--r--server/src/routes/ui/error.rs58
1 files changed, 23 insertions, 35 deletions
diff --git a/server/src/routes/ui/error.rs b/server/src/routes/ui/error.rs
index 011847e..b07ca8b 100644
--- a/server/src/routes/ui/error.rs
+++ b/server/src/routes/ui/error.rs
@@ -1,31 +1,27 @@
+use super::layout::DynLayoutPage;
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,
response::{self, Responder},
- Request, Response,
+ Request,
};
-use std::{fmt::Display, io::Cursor};
+use std::fmt::Display;
#[catch(default)]
-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 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()).to_string()] { "log in" } ", to see this page" }
+ }
+ },
+ }
}
pub type MyResult<T> = Result<T, MyError>;
@@ -34,23 +30,15 @@ pub type MyResult<T> = Result<T, MyError>;
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();
- // 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!()
+ fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
+ LayoutPage {
+ title: "Error".to_string(),
+ content: markup::new! {
+ h2 { "An error occured. Nobody is sorry"}
+ pre.error { @format!("{:?}", self.0) }
+ },
+ }
+ .respond_to(req)
}
}