Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report hours parsing error to user as well as to the error log #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Report hours parsing error to user as well as to the error log
technetos committed Dec 6, 2020
commit 7a159f30db6c935eb189c05ba92ebbe142f734d0
10 changes: 8 additions & 2 deletions src/ban.rs
Original file line number Diff line number Diff line change
@@ -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