python: Catch specific exceptions from requests.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-10-08 18:32:34 -07:00
committed by Tim Abbott
parent 17ac17286c
commit 7f69c1d3d5
4 changed files with 12 additions and 12 deletions

View File

@@ -449,7 +449,7 @@ def fetch_open_graph_image(url: str) -> Optional[Dict[str, Any]]:
# TODO: What if response content is huge? Should we get headers first?
try:
content = requests.get(url, timeout=1).text
except Exception:
except requests.RequestException:
return None
# Extract the head and meta tags
# All meta tags are self closing, have no children or are closed