Better API feedback

This commit is contained in:
Florian Dupret 2021-04-28 19:45:13 +02:00
commit b9a63e59b7
2 changed files with 9 additions and 3 deletions

View file

@ -28,7 +28,7 @@ def create_meal_plan(
): ):
""" Creates a meal plan database entry """ """ Creates a meal plan database entry """
processed_plan = process_meals(session, data) processed_plan = process_meals(session, data)
db.meals.create(session, processed_plan.dict()) return db.meals.create(session, processed_plan.dict())
@router.put("/{plan_id}") @router.put("/{plan_id}")

View file

@ -35,7 +35,10 @@ async def create_recipe_category(
): ):
""" Creates a Category in the database """ """ Creates a Category in the database """
try:
return db.categories.create(session, category.dict()) return db.categories.create(session, category.dict())
except:
raise HTTPException( status.HTTP_400_BAD_REQUEST )
@router.put("/{category}", response_model=RecipeCategoryResponse) @router.put("/{category}", response_model=RecipeCategoryResponse)
@ -47,7 +50,10 @@ async def update_recipe_category(
): ):
""" Updates an existing Tag in the database """ """ Updates an existing Tag in the database """
try:
return db.categories.update(session, category, new_category.dict()) return db.categories.update(session, category, new_category.dict())
except:
raise HTTPException( status.HTTP_400_BAD_REQUEST )
@router.delete("/{category}") @router.delete("/{category}")