fix: Handle KeyError in platform info retrieval with clear message

This commit is contained in:
Paul Gauthier (aider) 2025-03-21 11:23:50 -07:00
parent 821662abcb
commit d6906fb100

View file

@ -1033,10 +1033,10 @@ class Coder:
platform_text = "" platform_text = ""
try: try:
platform_text = f"- Platform: {platform.platform()}\n" platform_text = f"- Platform: {platform.platform()}\n"
except Exception: except (Exception, KeyError):
# Skip platform info if it can't be retrieved # Skip platform info if it can't be retrieved
pass platform_text = "- Platform information unavailable\n"
shell_var = "COMSPEC" if os.name == "nt" else "SHELL" shell_var = "COMSPEC" if os.name == "nt" else "SHELL"
shell_val = os.getenv(shell_var) shell_val = os.getenv(shell_var)
platform_text += f"- Shell: {shell_var}={shell_val}\n" platform_text += f"- Shell: {shell_var}={shell_val}\n"