Skip to content

Commit

Permalink
Merge pull request #284 from closeio/fix-locals-data-error-handling
Browse files Browse the repository at this point in the history
Catch locals serialization errors
  • Loading branch information
corps authored Sep 5, 2018
2 parents 527e326 + da9fdc5 commit 23619f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,10 @@ def _add_locals_data(trace_data, exc_info):
if keywordspec:
cur_frame['keywordspec'] = keywordspec
if _locals:
cur_frame['locals'] = dict((k, _serialize_frame_data(v)) for k, v in iteritems(_locals))
try:
cur_frame['locals'] = dict((k, _serialize_frame_data(v)) for k, v in iteritems(_locals))
except Exception:
log.exception('Error while serializing frame data.')

frame_num += 1

Expand Down
16 changes: 16 additions & 0 deletions rollbar/test/test_rollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,22 @@ def __init__(self, arg1):
self.assertEqual('arg1', payload['data']['body']['trace']['frames'][-1]['argspec'][1])
self.assertEqual(33, payload['data']['body']['trace']['frames'][-1]['locals']['arg1'])

@mock.patch('rollbar.send_payload')
def test_failed_locals_serialization(self, send_payload):

class tmp(object):
@property
def __class__(self):
foo()

try:
t = tmp()
raise Exception('trigger_serialize')
except:
rollbar.report_exc_info()

self.assertEqual(send_payload.called, True)

@mock.patch('rollbar.send_payload')
def test_args_lambda_no_args(self, send_payload):

Expand Down

0 comments on commit 23619f1

Please sign in to comment.