Skip to content

Commit 81995dc

Browse files
committed
add printing except stack function
1 parent f7f3a5a commit 81995dc

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed
152 Bytes
Binary file not shown.

dist/pydumpling-0.1.1.tar.gz

167 Bytes
Binary file not shown.

pydumpling/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import os.path
33
from .debug_dumpling import debug_dumpling, load_dumpling
4-
from .helpers import print_traceback
4+
from .helpers import print_traceback_and_except
55

66
DUMP_FILE_EXTENSION: str = ".dump"
77

@@ -47,7 +47,7 @@ def main() -> None:
4747
args = parser.parse_args()
4848
file_name = args.filename
4949
if args.print:
50-
tb = load_dumpling(file_name)["traceback"]
51-
print_traceback(tb)
50+
dumpling_ = load_dumpling(file_name)
51+
print_traceback_and_except(dumpling_)
5252
elif args.debug:
5353
debug_dumpling(file_name)

pydumpling/helpers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import linecache
22

33

4-
def print_traceback(traceback_obj):
4+
def print_traceback_and_except(dumpling_result):
5+
traceback_obj = dumpling_result["traceback"]
6+
except_extra = dumpling_result["exc_extra"]
7+
except_type = except_extra["exc_type"]
8+
except_value = except_extra["exc_value"]
9+
510
print("Traceback (most recent call last):")
611
while traceback_obj:
712
frame = traceback_obj.tb_frame
@@ -18,3 +23,4 @@ def print_traceback(traceback_obj):
1823

1924
if traceback_obj is None:
2025
break
26+
print(f"{except_type.__name__}: {except_value}")

0 commit comments

Comments
 (0)