From e82f2eed682cf4ed806a85eeb5c3fcb7b02dd565 Mon Sep 17 00:00:00 2001 From: RCPilot1604 Date: Tue, 12 Nov 2024 12:54:12 +0800 Subject: [PATCH] Bugfix for incorrect error message --- .../java/tutorlink/command/AddGradeCommand.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/tutorlink/command/AddGradeCommand.java b/src/main/java/tutorlink/command/AddGradeCommand.java index 40eccdee3d..a5c5271488 100644 --- a/src/main/java/tutorlink/command/AddGradeCommand.java +++ b/src/main/java/tutorlink/command/AddGradeCommand.java @@ -1,5 +1,7 @@ package tutorlink.command; +import java.util.ArrayList; +import java.util.List; import tutorlink.appstate.AppState; import tutorlink.commons.Commons; import tutorlink.component.Component; @@ -72,7 +74,18 @@ public CommandResult execute(AppState appState, HashMap hashmap) private void validateArguments(String matricNumber, String componentDescription, String scoreNumber) throws IllegalValueException { if (matricNumber == null || componentDescription == null || scoreNumber == null) { - throw new IllegalValueException(Commons.ERROR_NULL); + List nullParameters = new ArrayList<>(); + if (matricNumber == null) { + nullParameters.add(ARGUMENT_PREFIXES[0]); + } + if (componentDescription == null) { + nullParameters.add(ARGUMENT_PREFIXES[1]); + } + if (scoreNumber == null) { + nullParameters.add(ARGUMENT_PREFIXES[2]); + } + throw new IllegalValueException(String.format(Commons.ERROR_NULL, + String.join(", ", nullParameters))); } }