Handle transport errors

This commit is contained in:
Nexus 2024-02-23 23:14:34 +00:00
parent a282dea03a
commit 5a0070957f
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -277,6 +277,8 @@ def preview_url(
e.response.status_code,
f"Failed to fetch {e.response.url} - HTTP {e.response.status_code}: {e.response.text}"
)
except httpx.NetworkError as e:
raise HTTPException(502, f"Failed to fetch {url} - {e}")
if "text/html" not in response.headers.get("content-type", ""):
return {}