Merge branch 'master' of https://github.com/rg3/youtube-dl
[youtube-dl] / youtube_dl / utils.py
index e9336bcddcb11818b8abe58e490edac52740344c..8f856ee8c073dd9095f2b62b1567eabdb321c117 100644 (file)
@@ -8,6 +8,7 @@ import locale
 import os
 import re
 import sys
+import traceback
 import zlib
 import email.utils
 import json
@@ -410,6 +411,20 @@ def encodeFilename(s):
     else:
         return s.encode(sys.getfilesystemencoding(), 'ignore')
 
+
+class ExtractorError(Exception):
+    """Error during info extraction."""
+    def __init__(self, msg, tb=None):
+        """ tb, if given, is the original traceback (so that it can be printed out). """
+        super(ExtractorError, self).__init__(msg)
+        self.traceback = tb
+
+    def format_traceback(self):
+        if self.traceback is None:
+            return None
+        return u''.join(traceback.format_tb(self.traceback))
+
+
 class DownloadError(Exception):
     """Download Error exception.