Handle transport errors
This commit is contained in:
parent
a282dea03a
commit
5a0070957f
1 changed files with 2 additions and 0 deletions
|
@ -277,6 +277,8 @@ def preview_url(
|
||||||
e.response.status_code,
|
e.response.status_code,
|
||||||
f"Failed to fetch {e.response.url} - HTTP {e.response.status_code}: {e.response.text}"
|
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", ""):
|
if "text/html" not in response.headers.get("content-type", ""):
|
||||||
return {}
|
return {}
|
||||||
|
|
Loading…
Reference in a new issue