Skip to content

Commit

Permalink
fix: fetch_taxonomy should check response status
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel committed Mar 28, 2022
1 parent 5b9252d commit 26f318e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions robotoff/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Dict, Iterable, List, Optional, Set, Union

import orjson
import requests

from robotoff import settings
from robotoff.utils import get_logger, http_session
Expand Down Expand Up @@ -274,6 +275,10 @@ def fetch_taxonomy(url: str, fallback_path: str, offline=False) -> Optional[Taxo

try:
r = http_session.get(url, timeout=120) # might take some time
if r.status_code >= 300:
raise requests.HTTPError(
"Taxonomy download at %s returned status code {r.status_code}", url
)
data = r.json()
except Exception as e:
logger.exception(f"{type(e)} exception while fetching taxonomy at %s", url)
Expand Down

0 comments on commit 26f318e

Please sign in to comment.