make invalid ingredients/units into warnings

This commit is contained in:
Emi Vasilek 2023-11-01 23:23:33 +01:00
parent da38086e98
commit a4064a941d

View file

@ -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: