aboutsummaryrefslogtreecommitdiffstats
path: root/crates/yt_dlp/src/options.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-07 14:46:03 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-07 14:46:03 +0100
commitf894b396b3eee4310fe5f6f7202b32d22d293c4e (patch)
tree51cc15b24da4b94ed5f0776d9d5305c009cba17e /crates/yt_dlp/src/options.rs
parentfix(yt/db/get/txn_log): Order by `ROWID` instead of `timestamp` (diff)
downloadyt-f894b396b3eee4310fe5f6f7202b32d22d293c4e.zip
refactor(yt_dlp/python_error): Add context to every `wrap_exc` call
Otherwise it is hard to debug where the wrapped exception was thrown.
Diffstat (limited to 'crates/yt_dlp/src/options.rs')
-rw-r--r--crates/yt_dlp/src/options.rs48
1 files changed, 31 insertions, 17 deletions
diff --git a/crates/yt_dlp/src/options.rs b/crates/yt_dlp/src/options.rs
index a87473d..e3373b2 100644
--- a/crates/yt_dlp/src/options.rs
+++ b/crates/yt_dlp/src/options.rs
@@ -145,17 +145,20 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
{
// Setup the progress hook
if let Some(ph) = options.progress_hook {
- opts.set_item(intern!(py, "progress_hooks"), vec![ph(py).wrap_exc(py)?])
- .wrap_exc(py)?;
+ opts.set_item(
+ intern!(py, "progress_hooks"),
+ vec![ph(py).wrap_exc(py, "not having context")?],
+ )
+ .wrap_exc(py, "not having context")?;
}
// Setup the post_processor hook
if let Some(ph) = options.post_processor_hook {
opts.set_item(
intern!(py, "postprocessor_hooks"),
- vec![ph(py).wrap_exc(py)?],
+ vec![ph(py).wrap_exc(py, "not having context")?],
)
- .wrap_exc(py)?;
+ .wrap_exc(py, "not having context")?;
}
}
@@ -163,47 +166,58 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
// Unconditionally set a logger.
// Otherwise, yt_dlp will log to stderr.
- let ytdl_logger = setup_logging(py, "yt_dlp").wrap_exc(py)?;
+ let ytdl_logger = setup_logging(py, "yt_dlp").wrap_exc(py, "not having context")?;
opts.set_item(intern!(py, "logger"), ytdl_logger)
- .wrap_exc(py)?;
+ .wrap_exc(py, "not having context")?;
}
let inner = {
- let p_params = opts.into_bound_py_any(py).wrap_exc(py)?;
- let p_auto_init = true.into_bound_py_any(py).wrap_exc(py)?;
+ let p_params = opts
+ .into_bound_py_any(py)
+ .wrap_exc(py, "not having context")?;
+ let p_auto_init = true
+ .into_bound_py_any(py)
+ .wrap_exc(py, "not having context")?;
py.import(intern!(py, "yt_dlp.YoutubeDL"))
- .wrap_exc(py)?
+ .wrap_exc(py, "not having context")?
.getattr(intern!(py, "YoutubeDL"))
- .wrap_exc(py)?
+ .wrap_exc(py, "not having context")?
.call1(
PyTuple::new(
py,
[
- p_params.into_bound_py_any(py).wrap_exc(py)?,
- p_auto_init.into_bound_py_any(py).wrap_exc(py)?,
+ p_params
+ .into_bound_py_any(py)
+ .wrap_exc(py, "not having context")?,
+ p_auto_init
+ .into_bound_py_any(py)
+ .wrap_exc(py, "not having context")?,
],
)
- .wrap_exc(py)?,
+ .wrap_exc(py, "not having context")?,
)
- .wrap_exc(py)?
+ .wrap_exc(py, "not having context")?
};
{
// Setup the post processors
let add_post_processor_fun = inner
.getattr(intern!(py, "add_post_processor"))
- .wrap_exc(py)?;
+ .wrap_exc(py, "not having context")?;
for pp in options.post_processors {
add_post_processor_fun
.call(
- (pp(py).wrap_exc(py)?.into_bound_py_any(py).wrap_exc(py)?,),
+ (pp(py)
+ .wrap_exc(py, "not having context")?
+ .into_bound_py_any(py)
+ .wrap_exc(py, "not having context")?,),
// "when" can take any value in yt_dlp.utils.POSTPROCESS_WHEN
py_kw_args!(py => when = "pre_process"),
)
- .wrap_exc(py)?;
+ .wrap_exc(py, "not having context")?;
}
}