Skip to content

Commit

Permalink
Show more thorough traces of exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Mar 15, 2012
1 parent 13f91e1 commit 053d383
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions builderror.py
Expand Up @@ -16,12 +16,19 @@ def printMessage(self):
print message
if self.originalTrace:
print "Traceback (most recent call last):"
for frame in self.originalTrace:
print " File \"%s\", line %s, in %s" % (frame[1], frame[2], frame[3])
self.printTrace(self)

def extendMessage(self, message, exception):
if exception:
message += ": " + str(exception)
if "originalException" in exception.__dict__ and exception.originalException:
message = self.extendMessage(message, exception.originalException)
return message

def printTrace(self, exception):
if "originalTrace" in exception.__dict__ and exception.originalTrace:
for frame in exception.originalTrace:
print " File \"%s\", line %s, in %s" % (frame[1], frame[2], frame[3])

if "originalException" in exception.__dict__ and exception.originalException:
self.printTrace(exception.originalException)

0 comments on commit 053d383

Please sign in to comment.