From fb751fa0959fc99bc662e273a7aedffb0d335801 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 25 Aug 2024 15:51:12 +0200 Subject: fix(select/duration): Report parse errors, as the input is user specified --- src/select/selection_file/duration.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/select') diff --git a/src/select/selection_file/duration.rs b/src/select/selection_file/duration.rs index f7a39cb..a38981c 100644 --- a/src/select/selection_file/duration.rs +++ b/src/select/selection_file/duration.rs @@ -23,9 +23,11 @@ impl FromStr for Duration { fn from_str(s: &str) -> Result { fn parse_num(str: &str, suffix: char) -> Result { str.strip_suffix(suffix) - .expect("it has a 'h' suffix") + .with_context(|| { + format!("Failed to strip suffix '{}' of number: '{}'", suffix, str) + })? .parse::() - .context("Failed to parse hours") + .with_context(|| format!("Failed to parse '{}'", suffix)) } if s == "[No Duration]" { -- cgit 1.4.1