File tree Expand file tree Collapse file tree
src/sap_cloud_sdk/agentgateway Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ async def list_mcp_tools(
171171 raise
172172 except Exception as e :
173173 logger .exception ("Unexpected error during tool discovery" )
174- raise AgentGatewaySDKError (f"Tool discovery failed: { e } " ) from e
174+ cause = _unwrap_exception_group (e )
175+ raise AgentGatewaySDKError (f"Tool discovery failed: { cause } " ) from e
175176
176177 @record_metrics (Module .AGENTGATEWAY , Operation .AGENTGATEWAY_CALL_MCP_TOOL )
177178 async def call_mcp_tool (
@@ -264,11 +265,19 @@ async def call_mcp_tool(
264265 raise
265266 except Exception as e :
266267 logger .exception ("Unexpected error during tool invocation" )
268+ cause = _unwrap_exception_group (e )
267269 raise AgentGatewaySDKError (
268- f"Tool invocation failed for '{ tool .name } ': { e } "
270+ f"Tool invocation failed for '{ tool .name } ': { cause } "
269271 ) from e
270272
271273
274+ def _unwrap_exception_group (exc : Exception ) -> Exception :
275+ """Unwrap nested ExceptionGroups to present meaningful error messages."""
276+ while isinstance (exc , BaseExceptionGroup ) and exc .exceptions :
277+ exc = exc .exceptions [0 ]
278+ return exc
279+
280+
272281def create_client (
273282 tenant_subdomain : str | Callable [[], str ] | None = None ,
274283 timeout : float = 60.0 ,
You can’t perform that action at this time.
0 commit comments