diff --git a/examples/java-matter-controller/java/src/com/matter/controller/Main.java b/examples/java-matter-controller/java/src/com/matter/controller/Main.java index ffeefb43699a2e..0e24c6dc1c212d 100644 --- a/examples/java-matter-controller/java/src/com/matter/controller/Main.java +++ b/examples/java-matter-controller/java/src/com/matter/controller/Main.java @@ -112,9 +112,6 @@ public static void main(String[] args) { try { commandManager.run(args); - } catch (IllegalArgumentException e) { - logger.log(Level.INFO, "Arguments init failed with exception: " + e.getMessage()); - System.exit(1); } catch (Exception e) { logger.log(Level.INFO, "Run command failed with exception: " + e.getMessage()); System.exit(1); diff --git a/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java b/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java index 2e1b373873478a..47e184ec3ae4d7 100644 --- a/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java +++ b/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java @@ -96,8 +96,14 @@ public final void run(String[] args) throws Exception { // need skip over binary and command name and only get arguments String[] temp = Arrays.copyOfRange(args, 2, args.length); - command.initArguments(temp.length, temp); - showCommand(args[0], command); + try { + command.initArguments(temp.length, temp); + } catch (IllegalArgumentException e) { + logger.log(Level.INFO, "Arguments init failed with exception: " + e.getMessage()); + showCommand(args[0], command); + System.exit(1); + } + command.run(); }