From 83f31d3cc0d264341b6757551f65109e8e497435 Mon Sep 17 00:00:00 2001 From: Tan Yiming Date: Fri, 3 Nov 2023 09:48:03 +0800 Subject: [PATCH] Handle errors when the b/ and m/ args are invalid --- .../band/AddMusicianToBandCommandParser.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/band/AddMusicianToBandCommandParser.java b/src/main/java/seedu/address/logic/parser/band/AddMusicianToBandCommandParser.java index 3abba12635a..6f3816b228c 100644 --- a/src/main/java/seedu/address/logic/parser/band/AddMusicianToBandCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/band/AddMusicianToBandCommandParser.java @@ -33,17 +33,12 @@ public AddMusicianToBandCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddMusicianToBandCommand.MESSAGE_USAGE)); } - try { - Index bandIndex = ParserUtil.parseIndex(argMultimap.getValue(PREFIX_BINDEX).get()); - List musicianIndices = new ArrayList<>(); - for (String indexString : argMultimap.getAllValues(PREFIX_MINDEX)) { - musicianIndices.add(ParserUtil.parseIndex(indexString)); - } - return new AddMusicianToBandCommand(bandIndex, musicianIndices); - } catch (ParseException pe) { - throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddMusicianToBandCommand.MESSAGE_USAGE), pe); + Index bandIndex = ParserUtil.parseIndex(argMultimap.getValue(PREFIX_BINDEX).get()); + List musicianIndices = new ArrayList<>(); + for (String indexString : argMultimap.getAllValues(PREFIX_MINDEX)) { + musicianIndices.add(ParserUtil.parseIndex(indexString)); } + return new AddMusicianToBandCommand(bandIndex, musicianIndices); } /**