Skip to content

Commit

Permalink
Handle HTTPError
Browse files Browse the repository at this point in the history
This can be e.g. a 502 server error, bad gateway
  • Loading branch information
rolandgeider committed May 30, 2024
1 parent b8b0a90 commit 6154347
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wger/nutrition/models/ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@

# Third Party
from openfoodfacts import API
from requests import ConnectTimeout
from requests import (
ConnectTimeout,
HTTPError,
)

# wger
from wger.core.models import Language
Expand Down Expand Up @@ -428,6 +431,9 @@ def fetch_ingredient_from_off(cls, code: str):
except ConnectTimeout:
logger.info('Timeout from OFF')
return None
except HTTPError as e:
logger.info(f'Got HTTPError from OFF: {e}')
return None

if not result:
logger.info('Product not found')
Expand Down

0 comments on commit 6154347

Please sign in to comment.