Skip to content
This repository has been archived by the owner on Jun 11, 2018. It is now read-only.

Include exception info in Client._get_log_message #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 3 additions & 2 deletions opbeat/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ def _get_log_message(self, data):
# decode message so we can show the actual event
try:
data = self.decode(data)
except Exception:
message = '<failed decoding data>'
except Exception as exc:
message = '<failed decoding data ({0}: {1})>'.format(
exc.__class__.__name__, exc)
else:
message = data.pop('message', '<no message value>')
return message
Expand Down
6 changes: 6 additions & 0 deletions tests/client/client_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ def test_message_event(self):
self.assertFalse('stacktrace' in event)
self.assertTrue('timestamp' in event)

@mock.patch('opbeat.base.Client.decode', side_effect=Exception('boom!'))
def test_get_log_message_exception(self, decode):
message = self.client._get_log_message(0)
self.assertEquals(message, "<failed decoding data (Exception: boom!)>")
decode.assert_called_once_with(0)

# def test_stack_explicit_frames(self):
# def bar():
# return inspect.stack()
Expand Down