diff --git a/mealie/core/exceptions.py b/mealie/core/exceptions.py index 077a8644d..f1ad27144 100644 --- a/mealie/core/exceptions.py +++ b/mealie/core/exceptions.py @@ -52,5 +52,6 @@ class IncompleteData(Exception): """ This exception is raised when a user sends incomplete data to the API """ - - pass + def __init__(self, missing, *args, **kwargs): + Exception.__init__(*args, **kwargs): + self.missing = missing diff --git a/mealie/routes/recipe/recipe_crud_routes.py b/mealie/routes/recipe/recipe_crud_routes.py index 20065cf41..bdf9cf6ab 100644 --- a/mealie/routes/recipe/recipe_crud_routes.py +++ b/mealie/routes/recipe/recipe_crud_routes.py @@ -85,10 +85,10 @@ class RecipeController(BaseRecipeController): self.logger.error("No Entry Found on recipe controller action") raise HTTPException(status_code=404, detail=ErrorResponse.respond(message="No Entry Found")) elif thrownType == exceptions.IncompleteData: - self.logger.error("Incomplete data provided to API route") + self.logger.error("Incomplete data provided to API route:", ex.missing) raise HTTPException( status_code=400, - detail=ErrorResponse.respond(message="Some data were missing on the body of this API request"), + detail=ErrorResponse.respond(message=f"Field '{ex.missing}' missing on the body of this API request"), ) elif thrownType == sqlalchemy.exc.IntegrityError: self.logger.error("SQL Integrity Error on recipe controller action") diff --git a/mealie/services/recipe/recipe_service.py b/mealie/services/recipe/recipe_service.py index bfff077ae..a36deab27 100644 --- a/mealie/services/recipe/recipe_service.py +++ b/mealie/services/recipe/recipe_service.py @@ -393,7 +393,7 @@ class RecipeService(RecipeServiceBase): continue if getattr(new_data, field) is None: - raise exceptions.IncompleteData(f"Incomplete recipe, missing {field}") + raise exceptions.IncompleteData(field, f"Incomplete recipe, missing {field}") if recipe is None or recipe.settings is None: raise exceptions.NoEntryFound("Recipe not found.")