Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch locals serialization errors #284

Merged
merged 3 commits into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ def _add_locals_data(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 @@ -301,6 +301,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