aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/__init__.py
diff options
context:
space:
mode:
authorSimon Sawicki <contact@grub4k.xyz>2023-04-03 07:01:03 +0200
committerSimon Sawicki <contact@grub4k.xyz>2023-05-20 21:19:37 +0200
commitd2e84d5eb01c66fc5304e8566348d65a7be24ed7 (patch)
treef82034dfb296c3fb77ebe3afefd2a475f74c56aa /yt_dlp/__init__.py
parent447afb9eaa65bc677e3245c83e53a8e69c174a3c (diff)
[update] Better error handling
Authored by: pukkandan
Diffstat (limited to 'yt_dlp/__init__.py')
-rw-r--r--yt_dlp/__init__.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py
index 47ee3cc02..8806106d3 100644
--- a/yt_dlp/__init__.py
+++ b/yt_dlp/__init__.py
@@ -13,6 +13,7 @@ import optparse
import os
import re
import sys
+import traceback
from .compat import compat_shlex_quote
from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS
@@ -937,14 +938,18 @@ def _real_main(argv=None):
if opts.rm_cachedir:
ydl.cache.remove()
- updater = Updater(ydl, opts.update_self if isinstance(opts.update_self, str) else None)
- if opts.update_self and updater.update() and actual_use:
- if updater.cmd:
- return updater.restart()
- # This code is reachable only for zip variant in py < 3.10
- # It makes sense to exit here, but the old behavior is to continue
- ydl.report_warning('Restart yt-dlp to use the updated version')
- # return 100, 'ERROR: The program must exit for the update to complete'
+ try:
+ updater = Updater(ydl, opts.update_self if isinstance(opts.update_self, str) else None)
+ if opts.update_self and updater.update() and actual_use:
+ if updater.cmd:
+ return updater.restart()
+ # This code is reachable only for zip variant in py < 3.10
+ # It makes sense to exit here, but the old behavior is to continue
+ ydl.report_warning('Restart yt-dlp to use the updated version')
+ # return 100, 'ERROR: The program must exit for the update to complete'
+ except Exception:
+ traceback.print_exc()
+ ydl._download_retcode = 100
if not actual_use:
if pre_process: