about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:51:12 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:51:12 +0200
commitfb751fa0959fc99bc662e273a7aedffb0d335801 (patch)
tree092ba18a7a39f54795041e7a38097f63fde0763d
parentfix(downloader): Fallback to calculating the video size, before using hardcod... (diff)
downloadyt-fb751fa0959fc99bc662e273a7aedffb0d335801.tar.gz
yt-fb751fa0959fc99bc662e273a7aedffb0d335801.zip
fix(select/duration): Report parse errors, as the input is user specified
-rw-r--r--src/select/selection_file/duration.rs6
1 files changed, 4 insertions, 2 deletions
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<Self, Self::Err> {
         fn parse_num(str: &str, suffix: char) -> Result<u32> {
             str.strip_suffix(suffix)
-                .expect("it has a 'h' suffix")
+                .with_context(|| {
+                    format!("Failed to strip suffix '{}' of number: '{}'", suffix, str)
+                })?
                 .parse::<u32>()
-                .context("Failed to parse hours")
+                .with_context(|| format!("Failed to parse '{}'", suffix))
         }
 
         if s == "[No Duration]" {