File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,14 +91,15 @@ async def get_agent_card(
9191 except httpx .HTTPStatusError as e :
9292 raise AgentCardResolutionError (
9393 f'Failed to fetch agent card from { target_url } (HTTP { e .response .status_code } ): { e } ' ,
94+ status_code = e .response .status_code ,
9495 ) from e
9596 except json .JSONDecodeError as e :
9697 raise AgentCardResolutionError (
9798 f'Failed to parse JSON for agent card from { target_url } : { e } '
9899 ) from e
99100 except httpx .RequestError as e :
100101 raise AgentCardResolutionError (
101- f'Network communication error fetching agent card from { target_url } (HTTP 503) : { e } ' ,
102+ f'Network communication error fetching agent card from { target_url } : { e } ' ,
102103 ) from e
103104 except ParseError as e :
104105 raise AgentCardResolutionError (
Original file line number Diff line number Diff line change @@ -9,3 +9,7 @@ class A2AClientError(A2AError):
99
1010class AgentCardResolutionError (A2AClientError ):
1111 """Exception raised when an agent card cannot be resolved."""
12+
13+ def __init__ (self , message : str , status_code : int | None = None ) -> None :
14+ super ().__init__ (message )
15+ self .status_code = status_code
Original file line number Diff line number Diff line change @@ -221,6 +221,7 @@ async def test_get_agent_card_http_status_error(
221221 with pytest .raises (AgentCardResolutionError ) as exc_info :
222222 await resolver .get_agent_card ()
223223
224+ assert exc_info .value .status_code == status_code
224225 assert f'HTTP { status_code } ' in str (exc_info .value )
225226 assert 'Failed to fetch agent card' in str (exc_info .value )
226227
@@ -247,7 +248,6 @@ async def test_get_agent_card_request_error(
247248 )
248249 with pytest .raises (AgentCardResolutionError ) as exc_info :
249250 await resolver .get_agent_card ()
250- assert 'HTTP 503' in str (exc_info .value )
251251 assert 'Network communication error' in str (exc_info .value )
252252
253253 @pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments