From 43b46a8be4662172b1d17f2946c4b2399ea3e752 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Wed, 12 Jan 2022 09:20:20 +0900 Subject: [PATCH] Make email_signups::create return ErrorPage on error --- src/routes/email_signups.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/routes/email_signups.rs b/src/routes/email_signups.rs index fc868ead..7a364dd0 100644 --- a/src/routes/email_signups.rs +++ b/src/routes/email_signups.rs @@ -70,7 +70,7 @@ pub fn create( conn: DbConn, rockets: PlumeRocket, _enabled: signups::Email, -) -> Result { +) -> Result { let registration_open = Instance::get_local() .map(|i| i.open_registrations) .unwrap_or(true); @@ -87,14 +87,15 @@ pub fn create( } let mut form = form.into_inner(); form.email = form.email.trim().to_owned(); - form.validate().map_err(|err| { - render!(email_signups::new( + if let Err(err) = form.validate() { + return Ok(render!(email_signups::new( &(&conn, &rockets).to_context(), registration_open, &form, err )) - })?; + .into()); + } let res = EmailSignup::start(&conn, &form.email); if let Some(err) = res.as_ref().err() { return Ok(match err {