mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 09:44:59 +00:00
feat: add uncaught exception reporting functionality
This commit is contained in:
parent
387ade4427
commit
f63a095a37
1 changed files with 23 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import sys
|
||||
import urllib.parse
|
||||
import webbrowser
|
||||
import traceback
|
||||
|
||||
from aider import __version__
|
||||
|
||||
|
@ -48,6 +49,28 @@ def report_github_issue(issue_text, title=None):
|
|||
print(issue_url)
|
||||
|
||||
|
||||
def exception_handler(exc_type, exc_value, exc_traceback):
|
||||
# Format the traceback
|
||||
tb_lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
||||
tb_text = ''.join(tb_lines)
|
||||
|
||||
# Prepare the issue text
|
||||
issue_text = f"An uncaught exception occurred:\n\n```\n{tb_text}\n```"
|
||||
|
||||
# Report the issue
|
||||
report_github_issue(issue_text, title="Uncaught Exception")
|
||||
|
||||
# Call the default exception handler
|
||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||
|
||||
|
||||
def report_uncaught_exceptions():
|
||||
"""
|
||||
Set up the global exception handler to report uncaught exceptions.
|
||||
"""
|
||||
sys.excepthook = exception_handler
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
title = None
|
||||
if len(sys.argv) > 2:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue