about summary refs log tree commit diff stats
path: root/yt/src/watch/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'yt/src/watch/mod.rs')
-rw-r--r--yt/src/watch/mod.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/yt/src/watch/mod.rs b/yt/src/watch/mod.rs
index 3bcf1fc..5c76c12 100644
--- a/yt/src/watch/mod.rs
+++ b/yt/src/watch/mod.rs
@@ -10,7 +10,7 @@
 
 use std::collections::HashMap;
 
-use anyhow::Result;
+use anyhow::{Context, Result};
 use events::MpvEventHandler;
 use libmpv2::{events::EventContext, Mpv};
 use log::{debug, info, warn};
@@ -19,6 +19,7 @@ use crate::{
     app::App,
     cache::maintain,
     storage::video_database::{extractor_hash::ExtractorHash, getters::get_videos, VideoStatus},
+    unreachable::Unreachable,
 };
 
 pub mod events;
@@ -47,7 +48,9 @@ pub async fn watch(app: &App) -> Result<()> {
         info!("Found mpv.conf at '{}'!", config_path.display());
         mpv.execute(
             "load-config-file",
-            &[config_path.to_str().expect("This should be utf8-able")],
+            &[config_path
+                .to_str()
+                .context("Failed to parse the config path is utf8-stringt")?],
         )?;
     } else {
         warn!(
@@ -61,7 +64,9 @@ pub async fn watch(app: &App) -> Result<()> {
         info!("Found mpv.input.conf at '{}'!", input_path.display());
         mpv.execute(
             "load-input-conf",
-            &[input_path.to_str().expect("This should be utf8-able")],
+            &[input_path
+                .to_str()
+                .context("Failed to parse the input path as utf8 string")?],
         )?;
     } else {
         warn!(
@@ -85,9 +90,14 @@ pub async fn watch(app: &App) -> Result<()> {
     for play_thing in play_things {
         debug!("Adding '{}' to playlist.", play_thing.title);
 
-        let orig_cache_path = play_thing.cache_path.expect("Is cached and thus some");
-        let cache_path = orig_cache_path.to_str().expect("Should be vaild utf8");
-        let fmt_cache_path = format!("\"{}\"", cache_path);
+        let orig_cache_path = play_thing.cache_path.unreachable("Is cached and thus some");
+        let cache_path = orig_cache_path.to_str().with_context(|| {
+            format!(
+                "Failed to parse the cache_path of a video as utf8: '{}'",
+                orig_cache_path.display()
+            )
+        })?;
+        let fmt_cache_path = format!("\"{cache_path}\"");
 
         let args = &[&fmt_cache_path, "append-play"];