From 7a159f30db6c935eb189c05ba92ebbe142f734d0 Mon Sep 17 00:00:00 2001 From: technetos Date: Sat, 5 Dec 2020 22:17:01 -0500 Subject: [PATCH] Report hours parsing error to user as well as to the error log --- src/ban.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ban.rs b/src/ban.rs index 76b799a..95a2dd2 100644 --- a/src/ban.rs +++ b/src/ban.rs @@ -102,11 +102,17 @@ pub(crate) fn temp_ban(args: Args) -> Result<()> { use std::str::FromStr; - let hours = u64::from_str( + let hours = match u64::from_str( args.params .get("hours") .ok_or("unable to retrieve hours param")?, - )?; + ) { + Ok(hours) => hours, + Err(e) => { + api::send_reply(&args, &format!("{}", e))?; + return Err(Box::new(e)); + } + }; let reason = args .params