diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-25 15:51:12 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-25 15:51:12 +0200 |
commit | fb751fa0959fc99bc662e273a7aedffb0d335801 (patch) | |
tree | 092ba18a7a39f54795041e7a38097f63fde0763d /src/select/selection_file/duration.rs | |
parent | fix(downloader): Fallback to calculating the video size, before using hardcod... (diff) | |
download | yt-fb751fa0959fc99bc662e273a7aedffb0d335801.tar.gz yt-fb751fa0959fc99bc662e273a7aedffb0d335801.zip |
fix(select/duration): Report parse errors, as the input is user specified
Diffstat (limited to 'src/select/selection_file/duration.rs')
-rw-r--r-- | src/select/selection_file/duration.rs | 6 |
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]" { |