Skip to content

Commit

Permalink
Merge pull request #194 from soons1/fix-OutofBoundsException
Browse files Browse the repository at this point in the history
Fix AOOB exception when parsing pair, unpair and logadd inputs
  • Loading branch information
gerteck authored Apr 14, 2024
2 parents 2c2bc86 + 0e179d3 commit 3917e0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public LogAddCommand parse(String args) throws ParseException {
try {
index1 = ParserUtil.parseIndex(pairIndexes[0]);
index2 = ParserUtil.parseIndex(pairIndexes[1]);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, LogAddCommand.MESSAGE_USAGE), pe);
} catch (ParseException | ArrayIndexOutOfBoundsException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, LogAddCommand.MESSAGE_USAGE), e);
}

String title = argMultimap.getValue(CliSyntax.PREFIX_TITLE).get().trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public PairCommand parse(String args) throws ParseException {
try {
index1 = ParserUtil.parseIndex(pairIndexes[0]);
index2 = ParserUtil.parseIndex(pairIndexes[1]);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, PairCommand.MESSAGE_USAGE), pe);
} catch (ParseException | ArrayIndexOutOfBoundsException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, PairCommand.MESSAGE_USAGE), e);
}

return new PairCommand(index1, index2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public UnpairCommand parse(String args) throws ParseException {
try {
index1 = ParserUtil.parseIndex(pairIndexes[0]);
index2 = ParserUtil.parseIndex(pairIndexes[1]);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, UnpairCommand.MESSAGE_USAGE), pe);
} catch (ParseException | ArrayIndexOutOfBoundsException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, UnpairCommand.MESSAGE_USAGE), e);
}

return new UnpairCommand(index1, index2);
Expand Down

0 comments on commit 3917e0d

Please sign in to comment.