Skip to content

Commit

Permalink
fixed minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
eejian97 committed Sep 30, 2019
1 parent 111b333 commit ea1d0fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Date;
import java.util.InputMismatchException;

Expand Down Expand Up @@ -38,6 +39,10 @@ public static Deadline genDeadlineTask(String cmd) {
LocalTime time = LocalTime.parse(dateTime[1], DateTimeFormatter.ofPattern("HHmm"));
return new Deadline(desc, date, time);

} catch (DateTimeParseException e) {
throw new DukeIllegalArgumentException("The input for Deadline is invalid. "
+ "Please ensure you input <description>, <Date> in d/MM/yyyy format, "
+ "and <Time> in HHmm format.");
} catch (StringIndexOutOfBoundsException e) {
throw new DukeIllegalArgumentException("The description of a Deadline cannot be empty.");

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Date;

public class Event extends Task {
Expand Down Expand Up @@ -36,6 +37,10 @@ public static Event genEventTask(String cmd) {
LocalTime time = LocalTime.parse(dateTime[1], DateTimeFormatter.ofPattern("HHmm"));
return new Event(desc, date, time);

} catch (DateTimeParseException e) {
throw new DukeIllegalArgumentException("The input for Deadline is invalid. "
+ "Please ensure you input <description>, <Date> in d/MM/yyyy format, "
+ "and <Time> in HHmm format.");
} catch (StringIndexOutOfBoundsException e) {
throw new DukeIllegalArgumentException("The description of an Event cannot be empty.");

Expand Down

0 comments on commit ea1d0fd

Please sign in to comment.