From 70cc1f439d981241a207c5ff938d64d03e50ef5a Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Mon, 25 Dec 2023 22:15:38 +0200 Subject: [PATCH] Fix exception causes all over the codebase (#1014) --- autogen/agentchat/contrib/math_user_proxy_agent.py | 4 ++-- samples/apps/autogen-studio/autogenstudio/utils/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autogen/agentchat/contrib/math_user_proxy_agent.py b/autogen/agentchat/contrib/math_user_proxy_agent.py index 7abb970e6..67c86daf0 100644 --- a/autogen/agentchat/contrib/math_user_proxy_agent.py +++ b/autogen/agentchat/contrib/math_user_proxy_agent.py @@ -397,8 +397,8 @@ class WolframAlphaAPIWrapper(BaseModel): try: import wolframalpha - except ImportError: - raise ImportError("wolframalpha is not installed. " "Please install it with `pip install wolframalpha`") + except ImportError as e: + raise ImportError("wolframalpha is not installed. Please install it with `pip install wolframalpha`") from e client = wolframalpha.Client(wolfram_alpha_appid) values["wolfram_client"] = client diff --git a/samples/apps/autogen-studio/autogenstudio/utils/utils.py b/samples/apps/autogen-studio/autogenstudio/utils/utils.py index b2bfcd351..4306c897c 100644 --- a/samples/apps/autogen-studio/autogenstudio/utils/utils.py +++ b/samples/apps/autogen-studio/autogenstudio/utils/utils.py @@ -128,7 +128,7 @@ def serialize_file(file_path: str) -> Tuple[str, str]: file_content = file.read() base64_encoded_content = base64.b64encode(file_content).decode("utf-8") except Exception as e: - raise IOError(f"An error occurred while reading the file: {e}") + raise IOError(f"An error occurred while reading the file: {e}") from e return base64_encoded_content, file_type