From a7ce38544bf69bd3176b0526d48b6040bab11818 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 31 Oct 2025 17:59:27 +0000 Subject: [PATCH] Improve error handling for unsupported pets with structured responses --- pet-nutrition-service/server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pet-nutrition-service/server.js b/pet-nutrition-service/server.js index d53411f1..40b2308d 100644 --- a/pet-nutrition-service/server.js +++ b/pet-nutrition-service/server.js @@ -20,7 +20,15 @@ async function main () { const { pet_type } = req.params; const fact = await NutritionFact.findOne({ pet_type }); if (!fact) { - return res.status(404).json({ message: 'nutrition fact not found for the given pet_type' }); + // Get list of supported pet types for better error response + const supportedPets = await NutritionFact.distinct('pet_type'); + return res.status(404).json({ + error: 'Pet type not supported', + message: `Nutrition information not available for '${pet_type}'`, + pet_type: pet_type, + supported_pets: supportedPets, + suggestion: `Try one of these supported pets: ${supportedPets.join(', ')}` + }); } res.status(200).json(fact); } catch (error) {