Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kngys committed Nov 7, 2024
1 parent 967f524 commit d02bc70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public class Messages {
public static final String MESSAGE_DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";
public static final String MESSAGE_INVALID_AMOUNT = "Incorrect amount format or invalid amount!\n"
+ "Amount should be a number of up to 2 decimal places containing only digits (0-9) and 1 decimal point. "
+ "There should be at least 1 digit before the decimal point.";
+ "Amount should be a number of up to 2 decimal places.\n"
+ "Amount should contain only digits (0-9), at most 1 decimal point (.), and at most 1 minus sign (-).\n"
+ "If decimal point is used, there should be at least 1 digit before the decimal point.\n"
+ "If the minus sign is used, it should be the first character.";
public static final String MESSAGE_INVALID_DATE_FORMAT = "Incorrect date format or invalid date!\n"
+ "Date format: YYYY-MM-DD";
public static final String MESSAGE_INVALID_MONTH_FORMAT = "Incorrect month format or invalid month!\n"
Expand All @@ -45,6 +47,9 @@ public class Messages {
public static final String MESSAGE_EMPTY_OTHER_PARTY = "Other party should not be blank!";
public static final String MESSAGE_EMPTY_DATE = "Date should not be blank!";

public static final String MESSAGE_EMPTY_PERSON_LIST =
"Current person list is empty!\n" + "%1$s command must only be used on non-empty person list.";

public static final String MESSAGE_EMPTY_TRANSACTION_LIST =
"Invalid command: The current transaction list is empty.";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public CommandResult execute(Model model) throws CommandException {
}

List<Person> lastShownList = model.getFilteredPersonList();
if (lastShownList.isEmpty()) {
throw new CommandException(String.format(Messages.MESSAGE_EMPTY_PERSON_LIST, COMMAND_WORD));
}

if (index.getZeroBased() >= lastShownList.size()) {
logger.fine("CommandException caused by invalid index.");
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
Expand Down

0 comments on commit d02bc70

Please sign in to comment.