Skip to content

A programming framework for agentic AI

Fix exception causes all over the codebase (#1014)

Ram Rachum70cc1f439d98
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