Skip to content

Commit

Permalink
Inproved PolystorageError exceptions in log (#3732)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehych authored and willkg committed May 2, 2017
1 parent b91eeb2 commit 55beaf1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion socorro/external/crashstorage_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class PolyStorageError(Exception, collections.MutableSequence):
message - an optional over all error message
"""
def __init__(self, message=''):
super(PolyStorageError, self).__init__(self, message)
super(PolyStorageError, self).__init__(message)
self.exceptions = [] # the collection

def gather_current_exception(self):
Expand Down Expand Up @@ -494,6 +494,11 @@ def __setitem__(self, index, value):
this method is required by the MutableSequence abstract base class"""
self.exceptions.__setitem__(index, value)

def __str__(self):
return '%s %s' % (self.message,
','.join(repr(e[1]).encode('ascii', 'ignore')
for e in self.exceptions))


#==============================================================================
class PolyCrashStorage(CrashStorageBase):
Expand Down
5 changes: 5 additions & 0 deletions socorro/unittest/external/test_crashstorage_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ def test_polyerror(self):
[eq_(a[0], b) for a, b in zip(x, types)]
ok_(1 not in x)
ok_(str(x[0][1]), 'dwight')
ok_(
all(sample in str(x) for sample in
['hell', 'NameError', 'KeyError', 'AttributeError']),
x
)

x[0] = x[1]
eq_(x[0], x[1])
Expand Down

0 comments on commit 55beaf1

Please sign in to comment.