Skip to content

Commit

Permalink
handle exception in user exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hzliu committed Mar 23, 2017
1 parent 575c3f0 commit b53bda5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rqalpha/utils/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ def __repr__(self):
if len(self.stacks) == 0:
return self.msg

def _repr(v):
try:
return repr(v)
except Exception:
return 'UNREPRESENTABLE VALUE'

content = ["Traceback (most recent call last):"]
for filename, lineno, func_name, code, local_variables in self.stacks:
content.append(' File %s, line %s in %s' % (filename, lineno, func_name))
content.append(' %s' % (code, ))
for k, v in six.iteritems(local_variables):
content.append(' --> %s = %s' % (k, repr(v)))
content.append(' --> %s = %s' % (k, _repr(v)))
content.append('')
content.append("%s: %s" % (self.exc_type.__name__, self.msg))

Expand Down

0 comments on commit b53bda5

Please sign in to comment.