projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
049a0f4
)
[utils] Introduce YoutubeDLError base class for all youtube-dl exceptions
author
Pierre Mdawar
<p.mdawar@gmail.com>
Mon, 17 Oct 2016 11:38:37 +0000
(14:38 +0300)
committer
Sergey M
<dstftw@gmail.com>
Sat, 18 Feb 2017 21:10:08 +0000
(
05:10
+0800)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index 07c07be6f8f79193347e525a594b069e4afb5b36..3f9e592e36033b2377e72872e2826cfc1a00764b 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-701,7
+701,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."""
def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None):
"""Error during info extraction."""
def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None):
@@
-742,7
+747,7
@@
class RegexNotFoundError(ExtractorError):
pass
pass
-class DownloadError(
Exception
):
+class DownloadError(
YoutubeDLError
):
"""Download Error exception.
This exception may be thrown by FileDownloader objects if they are not
"""Download Error exception.
This exception may be thrown by FileDownloader objects if they are not
@@
-756,7
+761,7
@@
class DownloadError(Exception):
self.exc_info = exc_info
self.exc_info = exc_info
-class SameFileError(
Exception
):
+class SameFileError(
YoutubeDLError
):
"""Same File exception.
This exception will be thrown by FileDownloader objects if they detect
"""Same File exception.
This exception will be thrown by FileDownloader objects if they detect
@@
-765,7
+770,7
@@
class SameFileError(Exception):
pass
pass
-class PostProcessingError(
Exception
):
+class PostProcessingError(
YoutubeDLError
):
"""Post Processing exception.
This exception may be raised by PostProcessor's .run() method to
"""Post Processing exception.
This exception may be raised by PostProcessor's .run() method to
@@
-773,15
+778,16
@@
class PostProcessingError(Exception):
"""
def __init__(self, msg):
"""
def __init__(self, msg):
+ super(PostProcessingError, self).__init__(msg)
self.msg = msg
self.msg = msg
-class MaxDownloadsReached(
Exception
):
+class MaxDownloadsReached(
YoutubeDLError
):
""" --max-downloads limit has been reached. """
pass
""" --max-downloads limit has been reached. """
pass
-class UnavailableVideoError(
Exception
):
+class UnavailableVideoError(
YoutubeDLError
):
"""Unavailable Format exception.
This exception will be thrown when a video is requested
"""Unavailable Format exception.
This exception will be thrown when a video is requested
@@
-790,7
+796,7
@@
class UnavailableVideoError(Exception):
pass
pass
-class ContentTooShortError(
Exception
):
+class ContentTooShortError(
YoutubeDLError
):
"""Content Too Short exception.
This exception may be raised by FileDownloader objects when a file they
"""Content Too Short exception.
This exception may be raised by FileDownloader objects when a file they
@@
-799,12
+805,15
@@
class ContentTooShortError(Exception):
"""
def __init__(self, downloaded, expected):
"""
def __init__(self, downloaded, expected):
+ super(ContentTooShortError, self).__init__(
+ 'Downloaded {0} bytes, expected {1} bytes'.format(downloaded, expected)
+ )
# Both in bytes
self.downloaded = downloaded
self.expected = expected
# Both in bytes
self.downloaded = downloaded
self.expected = expected
-class XAttrMetadataError(
Exception
):
+class XAttrMetadataError(
YoutubeDLError
):
def __init__(self, code=None, msg='Unknown error'):
super(XAttrMetadataError, self).__init__(msg)
self.code = code
def __init__(self, code=None, msg='Unknown error'):
super(XAttrMetadataError, self).__init__(msg)
self.code = code
@@
-820,7
+829,7
@@
class XAttrMetadataError(Exception):
self.reason = 'NOT_SUPPORTED'
self.reason = 'NOT_SUPPORTED'
-class XAttrUnavailableError(
Exception
):
+class XAttrUnavailableError(
YoutubeDLError
):
pass
pass