fix(api): keep the error code a download failure names in the job error

This commit is contained in:
imSp4rky
2026-11-25 16:45:51 -07:00
parent d8058a3610
commit 2734177d94
2 changed files with 48 additions and 1 deletions
+3 -1
View File
@@ -474,7 +474,9 @@ def perform_download(
if outcome.error is not None:
# segment URLs carry signed CDN tokens (hmac, session IDs) that redact_text does not match
detail = redact_all(dl_instance.failure_lines(outcome.error)[1].strip())
raise APIError(APIErrorCode.WORKER_ERROR, f"download worker failed: {detail}")
named = (getattr(e, "error_code", None) for e in (outcome.error, outcome.error.__cause__))
code = next((c for c in named if isinstance(c, APIErrorCode)), APIErrorCode.WORKER_ERROR)
raise APIError(code, f"download worker failed: {detail}")
if progress_callback and outcome.skipped_subtitles:
progress_callback({"skipped_subtitles": outcome.skipped_subtitles})