@@ -26,7 +26,8 @@ public class Event extends Task {
2626 * @param toDate The end date of the event.
2727 * @param toTime The end time of the event.
2828 */
29- public Event (String description , LocalDate fromDate , LocalTime fromTime , LocalDate toDate , LocalTime toTime ) {
29+ public Event (String description , LocalDate fromDate , LocalTime fromTime , LocalDate toDate ,
30+ LocalTime toTime ) throws HelperBotArgumentException {
3031 super (description );
3132 this .fromDate = fromDate ;
3233 this .fromTime = fromTime ;
@@ -67,7 +68,8 @@ public static Event fromUserInput(String message) throws HelperBotArgumentExcept
6768 } catch (IndexOutOfBoundsException e ) {
6869 throw new HelperBotArgumentException ("Wrong format for Event" );
6970 } catch (DateTimeParseException e ) {
70- throw new HelperBotArgumentException ("Please enter date and time in YYYY-MM-DD hh:mm after /from and /to" );
71+ throw new HelperBotArgumentException ("Invalid date or time. "
72+ + "Please enter date and time in YYYY-MM-DD hh:mm after /from and /to" );
7173 }
7274 }
7375
@@ -165,13 +167,17 @@ private static Event getEvent(String[] message) throws HelperBotFileException {
165167 if (Event .isToBeforeFrom (fromDate , fromTime , toDate , toTime )) {
166168 throw new HelperBotFileException ("From datetime must be before to datetime" );
167169 }
168- Event event = new Event (message [2 ], fromDate , fromTime , toDate , toTime );
169- if (message [1 ].equals ("1" )) {
170- event .markAsDone ();
171- } else if (!message [1 ].equals ("0" )) {
172- throw new HelperBotFileException ("Invalid status " + message [0 ] + " for Task" );
170+ try {
171+ Event event = new Event (message [2 ], fromDate , fromTime , toDate , toTime );
172+ if (message [1 ].equals ("1" )) {
173+ event .markAsDone ();
174+ } else if (!message [1 ].equals ("0" )) {
175+ throw new HelperBotFileException ("Invalid status " + message [0 ] + " for Task" );
176+ }
177+ return event ;
178+ } catch (HelperBotArgumentException e ) {
179+ throw new HelperBotFileException ("Empty description." );
173180 }
174- return event ;
175181 }
176182
177183 private static boolean isToBeforeFrom (LocalDate fromDate , LocalTime fromTime ,
0 commit comments