Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Handle HTTPError

Roland Geider6154347b5837
diff --git a/wger/nutrition/models/ingredient.py b/wger/nutrition/models/ingredient.py
index 44ffee85f..de6f5f535 100644
--- a/wger/nutrition/models/ingredient.py
+++ b/wger/nutrition/models/ingredient.py
@@ -38,7 +38,10 @@ from django.utils.translation import gettext_lazy as _
# Third Party
from openfoodfacts import API
-from requests import ConnectTimeout
+from requests import (
+ ConnectTimeout,
+ HTTPError,
+)
# wger
from wger.core.models import Language
@@ -428,6 +431,9 @@ class Ingredient(AbstractLicenseModel, models.Model):
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')