Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error message #216

Merged
merged 15 commits into from
Nov 5, 2020

Conversation

tohyuting
Copy link

@tohyuting tohyuting commented Nov 3, 2020

Finished standardizing all error messages for invalid arguments. Will need to do a minor change, after merging in Update Command from Qin Liang's PR due to the change from name to index prefix.

There is one bug, where if a user key in:

edit ct/s i/ z/testing => this will not capture z/testing as invalid prefix, since the input will be trimmed(?) and the space will be gone. Appreciate any advice on this :)

@tohyuting tohyuting added this to the v1.4 milestone Nov 3, 2020
@tohyuting tohyuting marked this pull request as ready for review November 4, 2020 14:21
Copy link

@jeffreytjs jeffreytjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty insane work you have done here, can really see the time and effort put into resolving the many possible cases. Good work even with the tests too, this isn't an extensive review but more of spotting random typos while trying to see how you handle other test cases which can be applied to the question you post in the description.

The solution I am proposing would be to check for valid prefixes by regex, which by default rejects anything else. Can discuss more about this during our next meeting.

@@ -26,7 +26,8 @@

public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = "Finds all supplier(s) or warehouse(s) whose name,"
public static final String MESSAGE_USAGE = "Find Command Usage\n\nFinds all supplier(s) or warehouse(s)"
+ " whose name,"
+ " remark and/or name of products matches any of the specified keywords (case-insensitive) and displays"
+ " them as a list with index numbers. Prefixes provided can be in any order. At least one of the name,"
+ " remark or product prefixes along with its parameters must be provided.\n\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small issue but extra space here, commenting in case I miss it later

@@ -15,7 +15,8 @@
public class RemoveMacroCommand extends Command {
public static final String COMMAND_WORD = "removemacro";

public static final String MESSAGE_USAGE = "Removes the macro identified by the alias used in the macro list.\n\n"
public static final String MESSAGE_USAGE = "Remove Macro Usage\n\nRemoves the macro identified by the"
+ "alias used in the macro list.\n\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be missing a space here

@@ -20,4 +20,42 @@
public static final Prefix PREFIX_INDEX = new Prefix("i/");
public static final Prefix PREFIX_ALIAS = new Prefix("a/");
public static final Prefix PREFIX_COMMAND_STRING = new Prefix("cs/");
public static final Prefix[] ALLOWED_PREFIXES = new Prefix[] {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg this is a lot of effort you put in. I'm thinking if we can use regex on this to pick out all the invalid prefixes

}

if (!argMultimap.getValue(PREFIX_TYPE).isPresent()) {
throw new ParseException(String.format(MESSAGE_NO_PREFIX, EditCommand.MESSAGE_USAGE));
// Check if arguments are valid

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work including comments for better readability

@@ -220,6 +252,88 @@ public static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Pref
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
}

/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work abstracting all these out, it's still a headache that within each command there are so many different things to check for.

Copy link

@Criss-Wang Criss-Wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good logic-wise, thanks a lot for fixing the error messages!

Copy link

@qlchan24 qlchan24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qlchan24 qlchan24 merged commit f78b724 into AY2021S1-CS2103-W14-4:master Nov 5, 2020
@jeffreytjs jeffreytjs linked an issue Nov 6, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PE-D] Different error than expected
4 participants