From 8472c4bbf19a2fcbd8b0bda939e73af8739a54f9 Mon Sep 17 00:00:00 2001 From: ziyi105 Date: Mon, 13 Nov 2023 10:43:58 +0800 Subject: [PATCH] Update error message for decoding pantry stock data Fixes #323 --- src/main/java/seedu/cafectrl/storage/Decoder.java | 8 ++++---- src/main/java/seedu/cafectrl/ui/ErrorMessages.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/cafectrl/storage/Decoder.java b/src/main/java/seedu/cafectrl/storage/Decoder.java index 5df4e95e78..923952a071 100644 --- a/src/main/java/seedu/cafectrl/storage/Decoder.java +++ b/src/main/java/seedu/cafectrl/storage/Decoder.java @@ -107,7 +107,7 @@ public static Pantry decodePantryStockData(ArrayList encodedPantryStock) logger.info("Line to decode: " + encodedData); String[] decodedData = encodedData.split(DIVIDER); if (!isValidPantryStockFormat(decodedData)) { - ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); + ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_S346TOCK_DATA + encodedData); continue; } String ingredientName = decodedData[0].trim(); @@ -120,7 +120,7 @@ public static Pantry decodePantryStockData(ArrayList encodedPantryStock) qty = Integer.parseInt(qtyText); } catch (NumberFormatException e) { logger.log(Level.WARNING, "Line corrupted: " + e.getMessage(), e); - ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); + ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA + encodedData); continue; } @@ -131,8 +131,8 @@ && isValidUnit(unit)) { ingredient = new Ingredient(ingredientName, qty, unit); pantryStock.add(ingredient); } else { - logger.info(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); - ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA); + logger.info(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA + encodedData); + ui.showToUser(ErrorMessages.ERROR_IN_PANTRY_STOCK_DATA + encodedData); } } return new Pantry(ui, pantryStock); diff --git a/src/main/java/seedu/cafectrl/ui/ErrorMessages.java b/src/main/java/seedu/cafectrl/ui/ErrorMessages.java index a4e29d13c7..1b53116259 100644 --- a/src/main/java/seedu/cafectrl/ui/ErrorMessages.java +++ b/src/main/java/seedu/cafectrl/ui/ErrorMessages.java @@ -55,8 +55,8 @@ public class ErrorMessages { + "a new data folder has been created."; public static final String DISH_NOT_FOUND = "I'm sorry, but it appears that dish is so exclusive " + "it hasn't even made it to our menu yet!"; - public static final String ERROR_IN_PANTRY_STOCK_DATA = "Error in pantry stock data file! " - + "Skipping this particular ingredient!"; + public static final String ERROR_IN_PANTRY_STOCK_DATA = "pantry_stock.txt: Invalid format, " + + "this pantry stock will be removed -> "; public static final String UNIT_NOT_MATCHING = ": Sorry, you have used a " + "different unit for this ingredient!" + "\nUnit used previously: ";