Skip to content

Commit

Permalink
Merge pull request #347 from ziyi105/323-standardise-error-messages-f…
Browse files Browse the repository at this point in the history
…or-decoding-files

Task #323 standardise error messages for decoding files
  • Loading branch information
ziyi105 authored Nov 13, 2023
2 parents 0962c62 + af9d862 commit 8b103eb
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/seedu/cafectrl/storage/Decoder.java
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ public static Pantry decodePantryStockData(ArrayList<String> 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_STOCK_DATA + encodedData);
continue;
}
String ingredientName = decodedData[0].trim();
@@ -120,7 +120,7 @@ public static Pantry decodePantryStockData(ArrayList<String> 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);
4 changes: 2 additions & 2 deletions src/main/java/seedu/cafectrl/ui/ErrorMessages.java
Original file line number Diff line number Diff line change
@@ -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: ";

0 comments on commit 8b103eb

Please sign in to comment.