[utils] added YoutubeDLError superclass for all the exceptions

This commit is contained in:
Pierre Mdawar 2016-10-17 14:38:37 +03:00
parent 0b94dbb115
commit 60073843ba

View File

@ -675,7 +675,12 @@ def bug_reports_message():
return msg return msg
class ExtractorError(Exception): class YoutubeDLError(Exception):
"""Base exception for YoutubeDL errors."""
pass
class ExtractorError(YoutubeDLError):
"""Error during info extraction.""" """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):
@ -716,7 +721,7 @@ class RegexNotFoundError(ExtractorError):
pass pass
class DownloadError(Exception): class DownloadError(YoutubeDLError):
"""Download Error exception. """Download Error exception.
This exception may be thrown by FileDownloader objects if they are not This exception may be thrown by FileDownloader objects if they are not
@ -730,7 +735,7 @@ class DownloadError(Exception):
self.exc_info = exc_info self.exc_info = exc_info
class SameFileError(Exception): class SameFileError(YoutubeDLError):
"""Same File exception. """Same File exception.
This exception will be thrown by FileDownloader objects if they detect This exception will be thrown by FileDownloader objects if they detect
@ -739,7 +744,7 @@ class SameFileError(Exception):
pass pass
class PostProcessingError(Exception): class PostProcessingError(YoutubeDLError):
"""Post Processing exception. """Post Processing exception.
This exception may be raised by PostProcessor's .run() method to This exception may be raised by PostProcessor's .run() method to
@ -750,12 +755,12 @@ class PostProcessingError(Exception):
self.msg = msg self.msg = msg
class MaxDownloadsReached(Exception): class MaxDownloadsReached(YoutubeDLError):
""" --max-downloads limit has been reached. """ """ --max-downloads limit has been reached. """
pass pass
class UnavailableVideoError(Exception): class UnavailableVideoError(YoutubeDLError):
"""Unavailable Format exception. """Unavailable Format exception.
This exception will be thrown when a video is requested This exception will be thrown when a video is requested
@ -764,7 +769,7 @@ class UnavailableVideoError(Exception):
pass pass
class ContentTooShortError(Exception): class ContentTooShortError(YoutubeDLError):
"""Content Too Short exception. """Content Too Short exception.
This exception may be raised by FileDownloader objects when a file they This exception may be raised by FileDownloader objects when a file they
@ -778,7 +783,7 @@ class ContentTooShortError(Exception):
self.expected = expected self.expected = expected
class XAttrMetadataError(Exception): class XAttrMetadataError(YoutubeDLError):
def __init__(self, code=None, msg='Unknown error'): def __init__(self, code=None, msg='Unknown error'):
super(XAttrMetadataError, self).__init__(msg) super(XAttrMetadataError, self).__init__(msg)
self.code = code self.code = code
@ -794,7 +799,7 @@ class XAttrMetadataError(Exception):
self.reason = 'NOT_SUPPORTED' self.reason = 'NOT_SUPPORTED'
class XAttrUnavailableError(Exception): class XAttrUnavailableError(YoutubeDLError):
pass pass