Skip to content

Commit

Permalink
Fix error handling for event input formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DextheChik3n committed Sep 14, 2023
1 parent 8bc1e58 commit 1bc81a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/main/java/alan/Alan.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ public static void deadlineCommandHandler(String userInput, Task[] tasks, int cu
public static void eventCommandHandler(String userInput, Task[] tasks, int currentTasksIndex) throws AlanExceptions {
String filteredUserInput = userInput.replace("event ", "");
String[] splitDescriptionAndDate = filteredUserInput.split(" /from ");
String[] splitFromAndTo = splitDescriptionAndDate[1].split(" /to ");

checkEventInputFromFormat(splitDescriptionAndDate);

String[] splitFromAndTo = splitDescriptionAndDate[1].split(" /to ");

checkEventInputToFormat(splitFromAndTo);

String description = splitDescriptionAndDate[0];
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/alan/AlanExceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
public class AlanExceptions extends Exception {
public static final String INVALID_INPUT_COMMAND_MESSAGE = "Oof, I have no idea what are you saying duuude";
public static final String EMPTY_DESCRIPTION_MESSAGE = "Oof Dude, you can't leave the description empty";
public static final String INVALID_DEADLINE_FORMAT_MESSAGE = "Oof the deadline command isn't quite right you gotta fix the format, bro...\nRemember it's: <description> /by <date>";
public static final String INVALID_EVENT_FROM_FORMAT_MESSAGE = "Oof duude, your /from formatting is whack\nRemember it's: <description> /from <date> /to <date>";
public static final String INVALID_EVENT_TO_FORMAT_MESSAGE = "Oof my man, you need to work on that /to formatting\nRemember it's: <description> /from <date> /to <date>";
public static final String INVALID_DEADLINE_FORMAT_MESSAGE = "Oof the deadline command isn't quite right you gotta fix the format, bro...\n[Remember it's: <description> /by <date>]";
public static final String INVALID_EVENT_FROM_FORMAT_MESSAGE = "Oof duude, your /from formatting is whack\n[Remember it's: <description> /from <date> /to <date>]";
public static final String INVALID_EVENT_TO_FORMAT_MESSAGE = "Oof my man, you need to work on that /to formatting\n[Remember it's: <description> /from <date> /to <date>]";
public static final String INVALID_TASK_NUMBER_MESSAGE = "Oof maaaan there's no such task";
public AlanExceptions(String errorMessage) {
super(errorMessage);
Expand Down

0 comments on commit 1bc81a4

Please sign in to comment.