Skip to content
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
26 changes: 21 additions & 5 deletions python/humbug/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import concurrent.futures
from dataclasses import dataclass, field
from enum import Enum

import inspect
import logging
import os
import pkg_resources
Expand Down Expand Up @@ -140,7 +140,7 @@ def publish(self, report: Report, wait: bool = False) -> None:
timeout=self.timeout_seconds,
)
self.report_futures.append(report_future)
except:
except Exception:
pass

def custom_report(
Expand Down Expand Up @@ -379,7 +379,10 @@ def record_factory(*args, **kwargs):
self.is_loggerhook_set = True

def setup_excepthook(
self, tags: Optional[List[str]] = None, publish: bool = True
self,
tags: Optional[List[str]] = None,
publish: bool = True,
modules_whitelist: Optional[List[str]] = None,
) -> None:
"""
Adds error_report with python Exceptions.
Expand All @@ -392,9 +395,22 @@ def setup_excepthook(
original_excepthook = sys.excepthook

def _hook(exception_type, exception_instance, traceback):
self.error_report(error=exception_instance, tags=tags, publish=publish)
original_excepthook(exception_type, exception_instance, traceback)

module = inspect.getmodule(exception_type)
report_error = False
if modules_whitelist is None:
report_error = True
elif module is not None and modules_whitelist is not None:
for whitelisted_module in modules_whitelist:
if module.__name__.startswith(whitelisted_module):
report_error = True

if report_error:
self.error_report(
error=exception_instance, tags=tags, publish=publish
)

sys.excepthook = _hook

self.is_excepthook_set = True
Expand Down Expand Up @@ -484,5 +500,5 @@ def publish(self, report: Report, wait: bool = False) -> None:
timeout=self.timeout_seconds,
)
self.report_futures.append(report_future)
except:
except Exception:
pass
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="humbug",
version="0.2.1",
version="0.2.2",
packages=find_packages(),
install_requires=["requests"],
extras_require={
Expand Down