Skip to content

Commit 15b561b

Browse files
authored
Merge pull request #27 from cocolato/dev
merge dev
2 parents 40f0e1c + 942ac3b commit 15b561b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pydumpling/helpers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import sys
12
from traceback import print_tb, print_exception
3+
from .pydumpling import save_dumping
24

35

46
def print_traceback_and_except(dumpling_result):
@@ -10,3 +12,13 @@ def print_traceback_and_except(dumpling_result):
1012
print_exception(exc_type, exc_value, exc_tb)
1113
else:
1214
print_tb(exc_tb)
15+
16+
17+
def catch_any_exception():
18+
original_hook = sys.excepthook
19+
20+
def _hook(exc_type, exc_value, exc_tb):
21+
save_dumping(exc_info=(exc_type, exc_value, exc_tb))
22+
original_hook(exc_type, exc_value, exc_tb) # call sys original hook
23+
24+
sys.excepthook = _hook

pydumpling/pydumpling.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
__version__ = "0.1.4"
1212

1313

14-
def save_dumping(filename=None, tb=None):
14+
def save_dumping(filename=None, exc_info=None):
1515
try:
16-
if tb is None:
16+
if exc_info is None:
1717
exc_type, exc_value, exc_tb = sys.exc_info()
18+
else:
19+
exc_type, exc_value, exc_tb = exc_info
1820

1921
if filename is None:
20-
filename = "%s:%d.dump" % (
22+
filename = "%s-%d.dump" % (
2123
exc_tb.tb_frame.f_code.co_filename, exc_tb.tb_frame.f_lineno)
2224

2325
fake_tb = FakeTraceback(exc_tb)

0 commit comments

Comments
 (0)