From 66a64973d119d3d8c6ef48d4e12eceb0046979c7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 27 Jul 2017 13:54:26 +0200 Subject: [PATCH] Include exception info in Client._get_log_message --- opbeat/base.py | 5 +++-- tests/client/client_tests.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/opbeat/base.py b/opbeat/base.py index 07e82737..4ea1f9f5 100644 --- a/opbeat/base.py +++ b/opbeat/base.py @@ -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 = '' + except Exception as exc: + message = ''.format( + exc.__class__.__name__, exc) else: message = data.pop('message', '') return message diff --git a/tests/client/client_tests.py b/tests/client/client_tests.py index 63b43fb1..13eaa3f8 100644 --- a/tests/client/client_tests.py +++ b/tests/client/client_tests.py @@ -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, "") + decode.assert_called_once_with(0) + # def test_stack_explicit_frames(self): # def bar(): # return inspect.stack()