From 42372f27cb78677f94c88ca2a8175779d0cfe2d9 Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Thu, 6 Aug 2020 10:23:02 +0200 Subject: [PATCH] profiles: display pretty error page for not-found profiles --- src/web/vks_web.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/web/vks_web.rs b/src/web/vks_web.rs index cebb3d5..afe6d37 100644 --- a/src/web/vks_web.rs +++ b/src/web/vks_web.rs @@ -237,6 +237,12 @@ pub fn search( #[derive(Debug)] pub struct ParamEmail(crate::database::types::Email); +impl std::fmt::Display for ParamEmail { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0.as_str()) + } +} + use rocket::request::FromParam; use rocket::http::RawStr; @@ -261,9 +267,7 @@ pub fn render_profile( if let Some(_) = db.by_email(&q.0) { MyResponse::ok_bare("found-profile") } else { - MyResponse::not_found_plain( - format!("No key found for given e-mail address: {:?}", q) - ) + MyResponse::not_found(None, format!("No key found for given e-mail address: {}", q)) } }