Skip to content

Commit 961eea7

Browse files
committed
Fix other Notice usage
1 parent 909a395 commit 961eea7

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

honeybadger/core.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ def wrap_excepthook(self, func):
6060
sys.excepthook = self.exception_hook
6161

6262
def exception_hook(self, type, exception, exc_traceback):
63-
notice = Notice(
64-
exception=exception, thread_local=self.thread_local, config=self.config
65-
)
66-
self._send_notice(notice)
63+
self.notify(exception=exception)
6764
self.existing_except_hook(type, exception, exc_traceback)
6865

6966
def shutdown(self):

honeybadger/notice.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ def excluded_exception(self):
4949
return True
5050
return False
5151

52-
def _get_thread_context(self):
53-
if self.thread_local is None:
54-
return {}
55-
return getattr(self.thread_local, "context", {})
56-
5752
def _construct_tags(self, tags):
5853
"""
5954
Accepts either:

honeybadger/tests/test_core.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,27 @@ def fake_send(notice):
100100
assert set(captured["tags"]) == {"from_ctx", "another_tag", "explicit"}
101101

102102

103+
def test_exception_hook_calls_notify(monkeypatch):
104+
hb = Honeybadger()
105+
captured = {}
106+
107+
def fake_send(notice=None, **kwargs):
108+
captured["notified"] = notice
109+
return "sent"
110+
111+
def fake_existing_except_hook(*args, **kwargs):
112+
captured["hook"] = True
113+
114+
monkeypatch.setattr(hb, "_send_notice", fake_send)
115+
116+
exc = ValueError("fail!")
117+
hb.wrap_excepthook(fake_existing_except_hook)
118+
hb.exception_hook(ValueError, exc, None)
119+
120+
assert captured["notified"].exception == exc
121+
assert captured["hook"] is True
122+
123+
103124
def test_threading():
104125
hb = Honeybadger()
105126
hb.configure(api_key="aaa", environment="development") # Explicitly use development

0 commit comments

Comments
 (0)