Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
INCENDE committed Oct 15, 2016
1 parent 3ed0472 commit a245983
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/seedu/agendum/logic/commands/LoadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
public class LoadCommand extends Command {

public static final String COMMAND_WORD = "load";
public static final String MESSAGE_SUCCESS = "Data successfully loaded from:: %1$s";
public static final String MESSAGE_LOCATION_INVALID = "The specified file path is invalid.";
public static final String MESSAGE_SUCCESS = "Data successfully loaded from: %1$s";
public static final String MESSAGE_LOCATION_INVALID = "The specified file path is invalid: %1$s";
public static final String MESSAGE_FILE_WRONG_FORMAT = "The specified file is in the wrong format: %1$s";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Specify a file to load from. \n"
+ "Parameters: FILE_PATH\n"
Expand All @@ -26,9 +27,14 @@ public LoadCommand(String location) {
public CommandResult execute() {
assert loadLocation != null;

if(!isLoadLocationValid() || !isFileCorrectFormat()) {
if(!isLocationValid()) {
indicateAttemptToExecuteIncorrectCommand();
return new CommandResult(MESSAGE_LOCATION_INVALID);
return new CommandResult(String.format(MESSAGE_LOCATION_INVALID, loadLocation));
}

if(!isFileCorrectFormat()) {
indicateAttemptToExecuteIncorrectCommand();
return new CommandResult(String.format(MESSAGE_FILE_WRONG_FORMAT, loadLocation));
}

model.loadFromLocation(loadLocation);
Expand All @@ -39,7 +45,7 @@ private boolean isFileCorrectFormat() {
return XmlUtil.isFileCorrectFormat(loadLocation);
}

private boolean isLoadLocationValid() {
private boolean isLocationValid() {
return StringUtil.isValidFilePath(loadLocation);
}

Expand Down

0 comments on commit a245983

Please sign in to comment.