From 92adb8391aaf11b3864cd7f91e742c0f6f710319 Mon Sep 17 00:00:00 2001 From: modembcc Date: Mon, 15 Apr 2024 16:17:49 +0800 Subject: [PATCH 1/3] Fix error message --- .../seedu/address/logic/parser/AddPersonCommandParser.java | 2 ++ .../seedu/address/logic/parser/AssignTeamCommandParser.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/parser/AddPersonCommandParser.java b/src/main/java/seedu/address/logic/parser/AddPersonCommandParser.java index 1a8eae1027e..771081ac6e7 100644 --- a/src/main/java/seedu/address/logic/parser/AddPersonCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddPersonCommandParser.java @@ -40,6 +40,8 @@ public AddPersonCommand parse(String args) throws ParseException { throw new ParseException(String.format( MESSAGE_INVALID_COMMAND_FORMAT, AddPersonCommand.MESSAGE_USAGE)); + } catch (IllegalArgumentException e) { + throw new ParseException("Please enter valid names."); } } } diff --git a/src/main/java/seedu/address/logic/parser/AssignTeamCommandParser.java b/src/main/java/seedu/address/logic/parser/AssignTeamCommandParser.java index 1bf46e5ed75..5ee4e7180b5 100644 --- a/src/main/java/seedu/address/logic/parser/AssignTeamCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AssignTeamCommandParser.java @@ -8,6 +8,7 @@ import seedu.address.logic.commands.AssignTeamCommand; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Name; import seedu.address.model.project.Project; @@ -32,7 +33,7 @@ public AssignTeamCommand parse(String args) throws ParseException { List team = Arrays.stream(members.split(",")) .map(String::trim) .collect(Collectors.toList()); - if (team.stream().anyMatch(member -> member.length() == 0)) { + if (team.stream().anyMatch(member -> (member.length() == 0 || !Name.isValidName(member)))) { throw new ParseException("Please enter valid names"); } if ((team.size() == 0) || (projectName.length() == 0)) { From 23e243d0bcbc6d733e2263f86640c64ff6a802dc Mon Sep 17 00:00:00 2001 From: modembcc Date: Mon, 15 Apr 2024 16:23:51 +0800 Subject: [PATCH 2/3] Add error message --- .../seedu/address/logic/parser/DeletePersonCommandParser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java b/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java index 2b8d91b42fc..e1a26c2bba0 100644 --- a/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java @@ -32,6 +32,8 @@ public DeletePersonCommand parse(String args) throws ParseException { throw new ParseException("Please enter the member and the project field"); } return new DeletePersonCommand(new Member(memberName), new Project(new Name(projectName))); + } catch (IllegalArgumentException e) { + throw new ParseException("Please enter valid names."); } catch (Exception e) { throw new ParseException(String.format( MESSAGE_INVALID_COMMAND_FORMAT, From 5b95446f3cf16fd1233f1c9bfb7872cbfd0e6f00 Mon Sep 17 00:00:00 2001 From: modembcc Date: Mon, 15 Apr 2024 16:25:00 +0800 Subject: [PATCH 3/3] Add more error message --- .../seedu/address/logic/parser/AssignPersonCommandParser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/AssignPersonCommandParser.java b/src/main/java/seedu/address/logic/parser/AssignPersonCommandParser.java index ac8f2b76045..605661b3ab7 100644 --- a/src/main/java/seedu/address/logic/parser/AssignPersonCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AssignPersonCommandParser.java @@ -38,6 +38,8 @@ public AssignPersonCommand parse(String args) throws ParseException { } catch (IndexOutOfBoundsException e) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AssignPersonCommand.MESSAGE_USAGE)); + } catch (IllegalArgumentException e) { + throw new ParseException("Please enter valid names."); } } }