FIX: Raising Exceptions without traceback

This commit is contained in:
Victor Grau Serrat
2017-10-11 23:31:08 -06:00
parent 01aeb88e8f
commit c67cbedfbf
+12 -13
View File
@@ -1,17 +1,16 @@
import sys, inspect import sys, traceback
from catalyst.errors import ZiplineError from catalyst.errors import ZiplineError
class ZiplineErrorSilent(ZiplineError): def silent_except_hook(exctype, excvalue, exctraceback):
def __init__(self, **kwargs): if exctype in [SymbolNotFoundOnExchange,]:
msg = self.msg.format(**kwargs) fn = traceback.extract_tb(exctraceback)[-1][0]
try: ln = traceback.extract_tb(exctraceback)[-1][1]
ln = sys.exc_info()[-1].tb_lineno print "Error traceback: {1} (line {2})\n" \
fn = sys.exc_info()[-1].f_code.co_filename "{0.__name__}: {3}.".format(exctype, fn, ln, excvalue)
except AttributeError: else:
ln = inspect.currentframe().f_back.f_lineno sys.__excepthook__(exctype, excvalue, exctraceback)
fn = inspect.currentframe().f_back.f_code.co_filename
msg = "Error traceback: {1} (line {2})\n{0.__name__}: {3}.".format(type(self), fn, ln, msg) sys.excepthook = silent_except_hook
sys.exit(msg)
class ExchangeRequestError(ZiplineError): class ExchangeRequestError(ZiplineError):
@@ -153,7 +152,7 @@ class MismatchingBaseCurrenciesExchanges(ZiplineError):
).strip() ).strip()
class SymbolNotFoundOnExchange(ZiplineErrorSilent): class SymbolNotFoundOnExchange(ZiplineError):
""" """
Raised when a symbol() call contains a non-existant symbol. Raised when a symbol() call contains a non-existant symbol.
""" """