improve error message to model on fetch failure

This commit is contained in:
Jack Adamson 2024-11-29 12:23:18 +00:00
commit 960321f136
No known key found for this signature in database

View file

@ -95,10 +95,10 @@ async def fetch_url(url: str, user_agent: str) -> str:
async with AsyncClient() as client: async with AsyncClient() as client:
try: try:
response = await client.get( response = await client.get(
url, follow_redirects=True, headers={"User-Agent": user_agent} url, follow_redirects=True, headers={"User-Agent": user_agent}, timeout=30,
) )
except HTTPError: except HTTPError as e:
raise McpError(INTERNAL_ERROR, f"Failed to fetch {url}") raise McpError(INTERNAL_ERROR, f"Failed to fetch {url}: {e!r}")
if response.status_code >= 400: if response.status_code >= 400:
raise McpError( raise McpError(
INTERNAL_ERROR, INTERNAL_ERROR,