Skip to content

Commit

Permalink
Use a more informative message when there is a missing command descri…
Browse files Browse the repository at this point in the history
…ption
  • Loading branch information
zognin committed Sep 15, 2021
1 parent 1398dc1 commit 53d5813
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static int getTaskNumberFromMessage(String message) throws InvalidTaskNum
public static void validateDescriptionNotEmpty(CommandTypeEnum commandType, String description)
throws MissingCommandDescriptionException {
if (description.isEmpty()) {
throw new MissingCommandDescriptionException(commandType.toString());
throw new MissingCommandDescriptionException(commandType);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package exception;

import type.CommandTypeEnum;

/**
* Encapsulates an exception when a user inputs a command with an empty description,
* but the command requires a description.
Expand All @@ -10,10 +12,11 @@ public class MissingCommandDescriptionException extends DukeException {
*
* @param commandType Command type.
*/
public MissingCommandDescriptionException(String commandType) {
public MissingCommandDescriptionException(CommandTypeEnum commandType) {
super(String.format(
"The description of a %s command cannot be empty",
commandType
"The description of a %s command cannot be empty. Please enter the command in this format: %s",
commandType.toString(),
commandType.getFormat()
));
}
}

0 comments on commit 53d5813

Please sign in to comment.