mirror of https://github.com/apache/kafka.git
MINOR: Wrapping exceptions in usage for groups and metrics utility (#19151)
If specified an invalid option then an exception trace appears with `kafka-client-metrics.sh` and `kafka-groups.sh` utilities. Then once has to explicitly remove the invalid argument and append `--help` to fetch correct options. The PR fixes below error message to one with `cause` and `usage`. This behaviour is similar to `kafka-console-consumer.sh` and `kafka-console-share-consumer.sh` Reviewers: Andrew Schofield <aschofield@confluent.io>
This commit is contained in:
parent
d04cddeb71
commit
8b955b54da
|
@ -49,6 +49,7 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.OptionException;
|
||||
import joptsimple.OptionSpec;
|
||||
import joptsimple.OptionSpecBuilder;
|
||||
|
||||
|
@ -260,7 +261,11 @@ public class ClientMetricsCommand {
|
|||
.ofType(String.class)
|
||||
.withValuesSeparatedBy(',');
|
||||
|
||||
try {
|
||||
options = parser.parse(args);
|
||||
} catch (OptionException oe) {
|
||||
CommandLineUtils.printUsageAndExit(parser, oe.getMessage());
|
||||
}
|
||||
|
||||
checkArgs();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.OptionException;
|
||||
import joptsimple.OptionSpec;
|
||||
import joptsimple.OptionSpecBuilder;
|
||||
|
||||
|
@ -217,7 +218,11 @@ public class GroupsCommand {
|
|||
+ "This matches group type 'consumer', and group type 'classic' where the protocol type is 'consumer' or empty.");
|
||||
shareOpt = parser.accepts("share", "Filter the groups to show share groups.");
|
||||
|
||||
try {
|
||||
options = parser.parse(args);
|
||||
} catch (OptionException oe) {
|
||||
CommandLineUtils.printUsageAndExit(parser, oe.getMessage());
|
||||
}
|
||||
|
||||
checkArgs();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue