From 8a482b83e9baa867c7bbe02a1ee422d053a15d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 13 Feb 2022 21:25:37 +0100 Subject: [PATCH] print error messages --- mealapi/model/meal.py | 6 +++--- mealapi/resources/mealresource.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mealapi/model/meal.py b/mealapi/model/meal.py index eb01a6d..1f5ebe0 100644 --- a/mealapi/model/meal.py +++ b/mealapi/model/meal.py @@ -9,7 +9,7 @@ class Meal(db.Model): description = db.Column(db.Text, nullable=False) kcal = db.Column(db.Integer, nullable=True) price = db.Column(db.Integer, nullable=True) - spicy = db.Column(db.Boolean, nullable=False, default=False) - vegan = db.Column(db.Boolean, nullable=False, default=False) - glutenfree = db.Column(db.Boolean, nullable=False, default=False) + spicy = db.Column(db.Boolean, nullable=True, default=False) + vegan = db.Column(db.Boolean, nullable=True, default=False) + glutenfree = db.Column(db.Boolean, nullable=True, default=False) ingredients = db.relationship('Ingredient', backref='Meal', lazy='dynamic') diff --git a/mealapi/resources/mealresource.py b/mealapi/resources/mealresource.py index c5569ac..9f79be5 100644 --- a/mealapi/resources/mealresource.py +++ b/mealapi/resources/mealresource.py @@ -20,8 +20,8 @@ class MealBaseResource(Resource): db.session.add(mealobj.data) db.session.commit() return '', 204 - except ValidationError: - abort(406, "meal validation error") + except ValidationError as error: + abort(406, error.messages) def get(self): meals = Meal.query.all()