Skip to content

Commit

Permalink
fix: use innermost traceback frame for error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gauthier committed Aug 29, 2024
1 parent 96adf93 commit 725da4b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions aider/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,15 @@ def exception_handler(exc_type, exc_value, exc_traceback):

tb_text = "".join(tb_lines_with_basenames)

# Find the first non-frozen frame
while exc_traceback:
filename = exc_traceback.tb_frame.f_code.co_filename
if not filename.startswith("<frozen "):
break
exc_traceback = exc_traceback.tb_next

# Get the filename and line number
line_number = exc_traceback.tb_lineno
try:
basename = os.path.basename(filename)
except Exception:
basename = filename
# Find the innermost frame
innermost_tb = exc_traceback
while innermost_tb.tb_next:
innermost_tb = innermost_tb.tb_next

# Get the filename and line number from the innermost frame
filename = innermost_tb.tb_frame.f_code.co_filename
line_number = innermost_tb.tb_lineno
basename = os.path.basename(filename)

# Get the exception type name
exception_type = exc_type.__name__
Expand Down

0 comments on commit 725da4b

Please sign in to comment.