Skip to content

Commit f5ba76a

Browse files
committed
Rename some messages for clarity
1 parent d4f414f commit f5ba76a

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

src/main/java/duke/command/FindCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public FindCommand(String input) {
2626
* @param storage Storage for Duke
2727
* @return A String containing the response from the executed method.
2828
* @throws InvalidCommandException An exception telling ifthe command is invalid.
29-
* @throws KeywordNotFoundException An exception if the keyword provided can't be found.
29+
* @throws KeywordNotFoundException An exception if the keyword format is invalid.
3030
*/
3131
public String execute(TaskList tasks, Ui ui, Storage storage)
3232
throws InvalidCommandException, KeywordNotFoundException {
3333
String[] split = input.split(" ");
3434
if (split.length != 2) {
35-
throw new InvalidCommandException(Message.FIND_ERROR);
35+
throw new InvalidCommandException(Message.FIND_FORMAT_ERROR);
3636
}
3737
return tasks.findKeyword(input);
3838
}

src/main/java/duke/command/UpdateDescriptionCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public String execute(TaskList tasks, Ui ui, Storage storage) throws TaskIndexEx
3737
} catch (NumberFormatException e) {
3838
throw new TaskIndexException(Message.INDEX_ERROR);
3939
} catch (ArrayIndexOutOfBoundsException e) {
40-
throw new InvalidCommandException(Message.UPDATE_DESC_GENERAL_ERROR);
40+
throw new InvalidCommandException(Message.UPDATE_DESC_ERROR);
4141
}
4242
}
4343
}

src/main/java/duke/command/UpdateTimeCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public String execute(TaskList tasks, Ui ui, Storage storage)
4141
} catch (NumberFormatException e) {
4242
throw new TaskIndexException(Message.INDEX_ERROR);
4343
} catch (ArrayIndexOutOfBoundsException e) {
44-
throw new InvalidCommandException(Message.UPDATE_TIME_GENERAL_ERROR);
44+
throw new InvalidCommandException(Message.UPDATE_TIME_ERROR);
4545
}
4646

4747
try {

src/main/java/duke/core/Message.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public class Message {
3737

3838
public static final String DELETE_ERROR = "Sorry, invalid command!\nTry: delete <task index>";
3939

40-
public static final String DESCRIPTION_ERROR = "Oops! The description of a task can't be empty!";
40+
public static final String EMPTY_DESCRIPTION_ERROR = "Oops! The description of a task can't be empty!";
4141

4242
public static final String INDEX_ERROR = "Sounds like you have the wrong task index, "
4343
+ "I can't really hear you through your water bowl!";
4444

45-
public static final String TIME_ERROR = "Your date time format is incorrect.\n"
45+
public static final String TIME_FORMAT_ERROR = "Your date time format is incorrect.\n"
4646
+ "Try: yyyy-mm-dd HHmm";
4747

4848
public static final String EVENT_FORMAT_ERROR = "Your event format is incorrect.\n"
@@ -51,17 +51,17 @@ public class Message {
5151
public static final String DEADLINE_FORMAT_ERROR = "Your deadline format is incorrect.\n"
5252
+ "Try: deadline <description> /by <date time>";
5353

54-
public static final String FIND_ERROR = "Sorry, that format isn't right!\nTry: find <keyword>";
54+
public static final String FIND_FORMAT_ERROR = "Sorry, that format isn't right!\nTry: find <keyword>";
5555

5656
public static final String KEYWORD_ERROR = "Aww, Cute couldn't fish up any results from that keyword.";
5757

5858
public static final String UPDATE_GENERAL_ERROR = "Wrong command format! Try:\n"
5959
+ "'update description <index> <new description>' or 'update time <index> <new time>";
6060

61-
public static final String UPDATE_DESC_GENERAL_ERROR = "Wrong command format! Try:\n"
61+
public static final String UPDATE_DESC_ERROR = "Wrong command format! Try:\n"
6262
+ "update description <index> <new description>";
6363

64-
public static final String UPDATE_TIME_GENERAL_ERROR = "Wrong command format! Try:\n"
64+
public static final String UPDATE_TIME_ERROR = "Wrong command format! Try:\n"
6565
+ "update time <index> <new time>";
6666

6767
public static final String TODO_TIME_ERROR = "Oops, a todo doesn't have a time! Try again.";

src/main/java/duke/core/Parser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static String reformatDateAndTime(String time) throws InvalidCommandExcep
129129

130130
String[] split = time.trim().split(" ");
131131
if (split.length != 2) {
132-
throw new InvalidTimeFormatException(Message.TIME_ERROR);
132+
throw new InvalidTimeFormatException(Message.TIME_FORMAT_ERROR);
133133
}
134134

135135
Boolean dateMatches = split[0].matches(dateRegex);
@@ -138,7 +138,7 @@ public static String reformatDateAndTime(String time) throws InvalidCommandExcep
138138
result += parseDate(split[0]) + " ";
139139
result += parseTime(split[1]);
140140
} else {
141-
throw new InvalidTimeFormatException(Message.TIME_ERROR);
141+
throw new InvalidTimeFormatException(Message.TIME_FORMAT_ERROR);
142142
}
143143
return result;
144144
}
@@ -149,7 +149,7 @@ private static String parseDate(String date) throws InvalidTimeFormatException {
149149
String result = localDate.format(DateTimeFormatter.ofPattern("MMM d yyyy"));
150150
return result;
151151
} catch (DateTimeParseException e) {
152-
throw new InvalidTimeFormatException(Message.TIME_ERROR);
152+
throw new InvalidTimeFormatException(Message.TIME_FORMAT_ERROR);
153153
}
154154
}
155155

src/main/java/duke/core/Storage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void updateDescription(int idx, String input) throws InvalidCommandExcept
205205

206206
tempFile.renameTo(originalFile);
207207
} catch (StringIndexOutOfBoundsException e) {
208-
throw new InvalidCommandException(Message.UPDATE_DESC_GENERAL_ERROR);
208+
throw new InvalidCommandException(Message.UPDATE_DESC_ERROR);
209209
} catch (FileNotFoundException e) {
210210
Ui.printLines("File not found. Try again!");
211211
} catch (IOException e) {
@@ -258,7 +258,7 @@ public void updateTime(int idx, String input) throws InvalidCommandException, In
258258

259259
tempFile.renameTo(originalFile);
260260
} catch (StringIndexOutOfBoundsException e) {
261-
throw new InvalidTimeFormatException(Message.TIME_ERROR);
261+
throw new InvalidTimeFormatException(Message.TIME_FORMAT_ERROR);
262262
} catch (FileNotFoundException e) {
263263
Ui.printLines("File not found. Try again!");
264264
} catch (IOException e) {

src/main/java/duke/task/TaskList.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public String updateTime(int idx, String input)
158158
} catch (IndexOutOfBoundsException e) {
159159
throw new TaskIndexException(Message.INDEX_ERROR);
160160
} catch (Exception e) {
161-
throw new InvalidCommandException(Message.UPDATE_TIME_GENERAL_ERROR);
161+
throw new InvalidCommandException(Message.UPDATE_TIME_ERROR);
162162
}
163163
}
164164

@@ -171,7 +171,7 @@ public String updateTime(int idx, String input)
171171
*/
172172
public String manageTodo(Storage storage, String input) throws EmptyDescriptionException {
173173
if (input.split(" ").length == 1) {
174-
throw new EmptyDescriptionException(Message.DESCRIPTION_ERROR);
174+
throw new EmptyDescriptionException(Message.EMPTY_DESCRIPTION_ERROR);
175175
} else {
176176
String description = input.substring(input.indexOf(" ") + 1);
177177
Todo todo = new Todo(description, false);
@@ -271,7 +271,7 @@ private String extractDescription(String input, String taskType)
271271
int end = input.indexOf("/") - 1;
272272
result = input.substring(start, end);
273273
} catch (StringIndexOutOfBoundsException e) {
274-
throw new EmptyDescriptionException(Message.DESCRIPTION_ERROR);
274+
throw new EmptyDescriptionException(Message.EMPTY_DESCRIPTION_ERROR);
275275
}
276276

277277
return result;

0 commit comments

Comments
 (0)