aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-01-03 15:39:55 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-01-03 15:39:55 +0100
commit01951dda7a27d3bd2331f22ded5d33876cf1dad9 (patch)
tree2fad7a068fe58717130e2d2378e2ca40e492f90b /youtube_dl/utils.py
parent6e3dba168bd9662186f0071caf249e4d0c52beff (diff)
downloadyoutube-dl-01951dda7a27d3bd2331f22ded5d33876cf1dad9.tar.xz
Make ExtractorError usable for other causes
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 91e180326..8f856ee8c 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -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.