From 730e5bd831a1b688352f5ecfb620a0994e263402 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 11 Dec 2024 12:10:12 -0800 Subject: [PATCH] fix: add error handling for clipboard operations in copy_context command --- aider/commands.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 876b0a18b..3883adcba 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -1447,8 +1447,16 @@ Just show me the edits I need to make. """ - pyperclip.copy(markdown) - self.io.tool_output("Copied code context to clipboard.") + try: + pyperclip.copy(markdown) + self.io.tool_output("Copied code context to clipboard.") + except pyperclip.PyperclipException as e: + self.io.tool_error(f"Failed to copy to clipboard: {str(e)}") + self.io.tool_output( + "You may need to install xclip or xsel on Linux, or pbcopy on macOS." + ) + except Exception as e: + self.io.tool_error(f"An unexpected error occurred while copying to clipboard: {str(e)}") def expand_subdir(file_path):