Make ExtractorError usable for other causes

This commit is contained in:
Philipp Hagemeister 2013-01-03 15:39:55 +01:00
parent 6e3dba168b
commit 01951dda7a
3 changed files with 13 additions and 6 deletions

View file

@ -8,6 +8,7 @@ import locale
import os
import re
import sys
import traceback
import zlib
import email.utils
import json
@ -414,12 +415,15 @@ def encodeFilename(s):
class ExtractorError(Exception):
"""Error during info extraction."""
def __init__(self, msg, tb=None):
""" tb is the original traceback (so that it can be printed out) """
""" tb, if given, is the original traceback (so that it can be printed out). """
super(ExtractorError, self).__init__(msg)
if tb is None:
tb = sys.exc_info()[2]
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.