mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-30 20:24:53 +00:00
[extractor] Show video id in error messages if possible
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user