From cd764e4593e790fee62994655c5ccd2162183869 Mon Sep 17 00:00:00 2001 From: yijiano Date: Tue, 15 Oct 2024 21:13:57 +0800 Subject: [PATCH] Add handling of multiple spaces between arguments, improve exception text output --- src/main/java/seedu/pill/exceptions/ExceptionMessages.java | 2 +- src/main/java/seedu/pill/util/Parser.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/pill/exceptions/ExceptionMessages.java b/src/main/java/seedu/pill/exceptions/ExceptionMessages.java index ae9d2e5106..f928248917 100644 --- a/src/main/java/seedu/pill/exceptions/ExceptionMessages.java +++ b/src/main/java/seedu/pill/exceptions/ExceptionMessages.java @@ -1,7 +1,7 @@ package seedu.pill.exceptions; public enum ExceptionMessages { - INVALID_COMMAND ("Invalid command, please try again."), + INVALID_COMMAND ("Invalid command, please try again.\nType the 'help' command for a list of valid commands."), SAVE_ERROR ("Error saving to file, please try again."), LOAD_ERROR ("Error loading saved data"), INVALID_LINE_FORMAT ("File corrupted. Ignoring invalid line format..."), diff --git a/src/main/java/seedu/pill/util/Parser.java b/src/main/java/seedu/pill/util/Parser.java index 9747ce7c6b..606509a63f 100644 --- a/src/main/java/seedu/pill/util/Parser.java +++ b/src/main/java/seedu/pill/util/Parser.java @@ -30,7 +30,7 @@ public Parser(ItemMap items, Storage storage) { */ public void parseCommand(String input) { try { - String[] splitInput = input.split(" "); + String[] splitInput = input.split("\\s+"); if (splitInput.length > 3) { throw new PillException(ExceptionMessages.TOO_MANY_ARGUMENTS); }