Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 725da4b

Browse files
committedAug 29, 2024
fix: use innermost traceback frame for error reporting
1 parent 96adf93 commit 725da4b

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed
 

‎aider/report.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,15 @@ def exception_handler(exc_type, exc_value, exc_traceback):
7777

7878
tb_text = "".join(tb_lines_with_basenames)
7979

80-
# Find the first non-frozen frame
81-
while exc_traceback:
82-
filename = exc_traceback.tb_frame.f_code.co_filename
83-
if not filename.startswith("<frozen "):
84-
break
85-
exc_traceback = exc_traceback.tb_next
86-
87-
# Get the filename and line number
88-
line_number = exc_traceback.tb_lineno
89-
try:
90-
basename = os.path.basename(filename)
91-
except Exception:
92-
basename = filename
80+
# Find the innermost frame
81+
innermost_tb = exc_traceback
82+
while innermost_tb.tb_next:
83+
innermost_tb = innermost_tb.tb_next
84+
85+
# Get the filename and line number from the innermost frame
86+
filename = innermost_tb.tb_frame.f_code.co_filename
87+
line_number = innermost_tb.tb_lineno
88+
basename = os.path.basename(filename)
9389

9490
# Get the exception type name
9591
exception_type = exc_type.__name__

0 commit comments

Comments
 (0)
Please sign in to comment.