mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
refactor: simplify exception handling in traceback processing
This commit is contained in:
parent
b441c03461
commit
2ce6f1a682
1 changed files with 12 additions and 9 deletions
|
@ -61,15 +61,15 @@ def exception_handler(exc_type, exc_value, exc_traceback):
|
||||||
# Replace full paths with basenames in the traceback
|
# Replace full paths with basenames in the traceback
|
||||||
tb_lines_with_basenames = []
|
tb_lines_with_basenames = []
|
||||||
for line in tb_lines:
|
for line in tb_lines:
|
||||||
if "File " in line:
|
try:
|
||||||
parts = line.split('"')
|
if "File " in line:
|
||||||
if len(parts) > 1:
|
parts = line.split('"')
|
||||||
full_path = parts[1]
|
if len(parts) > 1:
|
||||||
try:
|
full_path = parts[1]
|
||||||
basename = os.path.basename(full_path)
|
basename = os.path.basename(full_path)
|
||||||
except Exception:
|
line = line.replace(full_path, basename)
|
||||||
basename = full_path
|
except Exception:
|
||||||
line = line.replace(full_path, basename)
|
pass
|
||||||
tb_lines_with_basenames.append(line)
|
tb_lines_with_basenames.append(line)
|
||||||
|
|
||||||
tb_text = "".join(tb_lines_with_basenames)
|
tb_text = "".join(tb_lines_with_basenames)
|
||||||
|
@ -83,7 +83,10 @@ def exception_handler(exc_type, exc_value, exc_traceback):
|
||||||
|
|
||||||
# Get the filename and line number
|
# Get the filename and line number
|
||||||
line_number = exc_traceback.tb_lineno
|
line_number = exc_traceback.tb_lineno
|
||||||
basename = os.path.basename(filename)
|
try:
|
||||||
|
basename = os.path.basename(filename)
|
||||||
|
except Exception:
|
||||||
|
basename = filename
|
||||||
|
|
||||||
# Get the exception type name
|
# Get the exception type name
|
||||||
exception_type = exc_type.__name__
|
exception_type = exc_type.__name__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue