diff --git a/recipes.py b/recipes.py index 9984c07..b828b4d 100644 --- a/recipes.py +++ b/recipes.py @@ -108,7 +108,10 @@ class PriceDB: self.unit = None if "unit" in dct: assert_type(dct, "unit", str) - self.unit = units.get(dct["unit"]) + try: + self.unit = units.get(dct["unit"]) + except RuntimeError as e: + issues.append(str(e)) return issues @@ -120,7 +123,10 @@ class IngredientInstance: assert_type(dct, "name", str) self.name = dct["name"] - self.ingredient = ingredients.get(self.name) + try: + self.ingredient = ingredients.get(self.name) + except RuntimeError as e: + issues.append(str(e)) self.amount = 1.0 if "amount" in dct: @@ -134,7 +140,10 @@ class IngredientInstance: self.unit = None if "unit" in dct: assert_type(dct, "unit", str) - self.unit = units.get(dct["unit"]) + try: + self.unit = units.get(dct["unit"]) + except RuntimeError as e: + issues.append(str(e)) self.note = "" if "note" in dct: