From ca506ba752f6c31237a72ef010edcf7b21ee8ddf Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Mon, 18 Mar 2024 14:08:57 -0400 Subject: [PATCH] Use nested exceptions in get_powershell_command (#2058) --- autogen/code_utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/autogen/code_utils.py b/autogen/code_utils.py index 230bc1638..b18b6588e 100644 --- a/autogen/code_utils.py +++ b/autogen/code_utils.py @@ -230,17 +230,15 @@ def get_powershell_command(): raise FileNotFoundError( "Neither powershell.exe nor pwsh.exe is present in the system. " "Please install PowerShell and try again. " - f"Original error: {e}" - ) + ) from e except NotADirectoryError as e: raise NotADirectoryError( "PowerShell is either not installed or its path is not given " "properly in the environment variable PATH. Please check the " "path and try again. " - f"Original error: {e}" - ) + ) from e except PermissionError as e: - raise PermissionError(f"No permission to run powershell. Original error: {e}") + raise PermissionError("No permission to run powershell.") from e def _cmd(lang):