From c43efe3e0f863c631e10bb7aa5d85a28648f61d2 Mon Sep 17 00:00:00 2001 From: CJerrong Date: Mon, 15 Apr 2024 23:43:30 +0800 Subject: [PATCH 1/2] Fix exception messages for logAdd command --- src/main/java/scrolls/elder/logic/commands/LogAddCommand.java | 2 +- src/main/java/scrolls/elder/logic/parser/ParserUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/scrolls/elder/logic/commands/LogAddCommand.java b/src/main/java/scrolls/elder/logic/commands/LogAddCommand.java index 0361edf0d01..89e30066059 100644 --- a/src/main/java/scrolls/elder/logic/commands/LogAddCommand.java +++ b/src/main/java/scrolls/elder/logic/commands/LogAddCommand.java @@ -49,7 +49,7 @@ public class LogAddCommand extends Command { + PREFIX_REMARKS + "was a good session "; public static final String MESSAGE_SUCCESS = "New log added!"; - public static final String MESSAGE_NEGATIVE_DURATION = "Duration cannot be negative."; + public static final String MESSAGE_NEGATIVE_DURATION = "Duration must be positive."; public static final String MESSAGE_PERSONS_NOT_PAIRED = "The volunteer and befriendee are not paired."; /** diff --git a/src/main/java/scrolls/elder/logic/parser/ParserUtil.java b/src/main/java/scrolls/elder/logic/parser/ParserUtil.java index c449e7ab5b8..7f31ab9aece 100644 --- a/src/main/java/scrolls/elder/logic/parser/ParserUtil.java +++ b/src/main/java/scrolls/elder/logic/parser/ParserUtil.java @@ -173,7 +173,7 @@ public static Integer parseInt(String num) throws ParseException { try { return Integer.parseInt(trimmedNum); } catch (NumberFormatException e) { - throw new ParseException("Invalid number format. Expected a number.", e); + throw new ParseException("Invalid number format. Expected an integer.", e); } } } From 41539d4087f77e69ab1a72c8fb341ecbdb52dff3 Mon Sep 17 00:00:00 2001 From: CJerrong Date: Mon, 15 Apr 2024 23:48:17 +0800 Subject: [PATCH 2/2] Fix wrong exception messages in logEdit --- src/main/java/scrolls/elder/logic/commands/LogEditCommand.java | 2 +- .../scrolls/elder/logic/parser/LogAddCommandParserTest.java | 2 +- .../scrolls/elder/logic/parser/LogEditCommandParserTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java b/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java index d8c0c1d9fc3..807b26c8d3c 100644 --- a/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java +++ b/src/main/java/scrolls/elder/logic/commands/LogEditCommand.java @@ -54,7 +54,7 @@ public class LogEditCommand extends Command { public static final String MESSAGE_EDIT_LOG_SUCCESS = "Edited Log successfully: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; - public static final String MESSAGE_NEGATIVE_DURATION = "Duration cannot be negative."; + public static final String MESSAGE_NEGATIVE_DURATION = "Duration must be positive."; private final Index index; private final EditLogDescriptor editLogDescriptor; diff --git a/src/test/java/scrolls/elder/logic/parser/LogAddCommandParserTest.java b/src/test/java/scrolls/elder/logic/parser/LogAddCommandParserTest.java index 70e48923851..ed02b035482 100644 --- a/src/test/java/scrolls/elder/logic/parser/LogAddCommandParserTest.java +++ b/src/test/java/scrolls/elder/logic/parser/LogAddCommandParserTest.java @@ -52,7 +52,7 @@ public void parse_invalidDateFormat_throwsParseException() { @Test public void parse_invalidDurationFormat_throwsParseException() { assertParseFailure(parser, "1 2 t/Movies s/2024-03-07 d/Two r/Good", - "Invalid number format. Expected a number."); + "Invalid number format. Expected an integer."); } @Test diff --git a/src/test/java/scrolls/elder/logic/parser/LogEditCommandParserTest.java b/src/test/java/scrolls/elder/logic/parser/LogEditCommandParserTest.java index aa778f5d5d0..424ac17e86a 100644 --- a/src/test/java/scrolls/elder/logic/parser/LogEditCommandParserTest.java +++ b/src/test/java/scrolls/elder/logic/parser/LogEditCommandParserTest.java @@ -80,7 +80,7 @@ public void parse_invalidDateFormat_throwsParseException() { @Test public void parse_invalidDurationFormat_throwsParseException() { assertParseFailure(parser, "1 t/Icebreaker s/2024-04-08 d/Two r/Was okay.", - "Invalid number format. Expected a number."); + "Invalid number format. Expected an integer."); } @Test public void parse_invalidArgs_throwsParseException() {