aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-08-19 07:19:23 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-08-23 02:49:07 +0530
commit1151c4079a15939c981f3e30129b82dea1b1bc6d (patch)
tree4e9fc1d4e531d0ed271a3fe51880bc62ae7e3294 /yt_dlp/utils.py
parent88acdbc2698169e22cdbf358e44765150434c69e (diff)
downloadhypervideo-pre-1151c4079a15939c981f3e30129b82dea1b1bc6d.tar.lz
hypervideo-pre-1151c4079a15939c981f3e30129b82dea1b1bc6d.tar.xz
hypervideo-pre-1151c4079a15939c981f3e30129b82dea1b1bc6d.zip
[extractor] Show video id in error messages if possible
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index c07a17099..61878b8d7 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -2399,25 +2399,27 @@ network_exceptions = tuple(network_exceptions)
class ExtractorError(YoutubeDLError):
"""Error during info extraction."""
- def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None):
+ def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None, ie=None):
""" tb, if given, is the original traceback (so that it can be printed out).
If expected is set, this is a normal error message and most likely not a bug in yt-dlp.
"""
-
if sys.exc_info()[0] in network_exceptions:
expected = True
- if video_id is not None:
- msg = video_id + ': ' + msg
- if cause:
- msg += ' (caused by %r)' % cause
- if not expected:
- msg += bug_reports_message()
- super(ExtractorError, self).__init__(msg)
+ self.msg = msg
self.traceback = tb
- self.exc_info = sys.exc_info() # preserve original exception
+ self.expected = expected
self.cause = cause
self.video_id = video_id
+ self.ie = ie
+ self.exc_info = sys.exc_info() # preserve original exception
+
+ super(ExtractorError, self).__init__(''.join((
+ format_field(ie, template='[%s] '),
+ format_field(video_id, template='%s: '),
+ msg,
+ format_field(cause, template=' (caused by %r)'),
+ '' if expected else bug_reports_message())))
def format_traceback(self):
if self.traceback is None: