From e5f7df7318326cab2286db34d2e2c1b930516684 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Thu, 15 Jan 2026 16:35:31 +0100 Subject: [PATCH] Fixed pipeline issues and added comment --- .../java/client/scenes/recipe/IngredientsPopupCtrl.java | 5 +++-- client/src/main/java/client/utils/server/ServerUtils.java | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/client/scenes/recipe/IngredientsPopupCtrl.java b/client/src/main/java/client/scenes/recipe/IngredientsPopupCtrl.java index 7d6a4f3..203fb91 100644 --- a/client/src/main/java/client/scenes/recipe/IngredientsPopupCtrl.java +++ b/client/src/main/java/client/scenes/recipe/IngredientsPopupCtrl.java @@ -68,8 +68,9 @@ public class IngredientsPopupCtrl { refresh(); // reload list from server } catch (IOException e) { if (e.getMessage() != null && e.getMessage().startsWith("DUPLICATE:")) { - showError("An ingredient with the name" + name + " already exists." + - " Please provide a different name."); + showError("An ingredient with the name " + name + " already exists." + + " Please provide a different name."); //checks if error received has the DUPLICATE string and creates a showError instance with an appropriate error message and description + } else { showError("Failed to create ingredient: " + e.getMessage()); } diff --git a/client/src/main/java/client/utils/server/ServerUtils.java b/client/src/main/java/client/utils/server/ServerUtils.java index 2d4bcc0..3e2aa7e 100644 --- a/client/src/main/java/client/utils/server/ServerUtils.java +++ b/client/src/main/java/client/utils/server/ServerUtils.java @@ -278,9 +278,9 @@ public class ServerUtils { .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - - if (response.statusCode() == 409) { - throw new IOException("An ingredient with the name '" + name + "' already exists."); + final int DUPLICATE_STATUS_CODE = 409; + if (response.statusCode() == DUPLICATE_STATUS_CODE) { + throw new IOException("DUPLICATE: An ingredient with the name '" + name + "' already exists."); } if (response.statusCode() != statusOK) {