Fixed pipeline issues and added comment

This commit is contained in:
Rithvik Sriram 2026-01-15 16:35:31 +01:00
commit e5f7df7318
2 changed files with 6 additions and 5 deletions

View file

@ -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());
}

View file

@ -278,9 +278,9 @@ public class ServerUtils {
.build();
HttpResponse<String> 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) {