From 01aeb88e8f9d10c060b13b705438c8cc8311982d Mon Sep 17 00:00:00 2001 From: Victor Grau Serrat Date: Wed, 11 Oct 2017 17:05:27 -0600 Subject: [PATCH] Raising Exceptions without traceback --- catalyst/exchange/exchange_errors.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/catalyst/exchange/exchange_errors.py b/catalyst/exchange/exchange_errors.py index 7e751981..f2629ef4 100644 --- a/catalyst/exchange/exchange_errors.py +++ b/catalyst/exchange/exchange_errors.py @@ -1,5 +1,18 @@ +import sys, inspect from catalyst.errors import ZiplineError +class ZiplineErrorSilent(ZiplineError): + def __init__(self, **kwargs): + msg = self.msg.format(**kwargs) + try: + ln = sys.exc_info()[-1].tb_lineno + fn = sys.exc_info()[-1].f_code.co_filename + except AttributeError: + ln = inspect.currentframe().f_back.f_lineno + 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.exit(msg) + class ExchangeRequestError(ZiplineError): msg = ( @@ -140,7 +153,7 @@ class MismatchingBaseCurrenciesExchanges(ZiplineError): ).strip() -class SymbolNotFoundOnExchange(ZiplineError): +class SymbolNotFoundOnExchange(ZiplineErrorSilent): """ Raised when a symbol() call contains a non-existant symbol. """