use of org.apache.pulsar.client.admin.PulsarAdminException.ConnectException in project incubator-pulsar by apache.
the class CmdBase method run.
public boolean run(String[] args) {
try {
jcommander.parse(args);
} catch (Exception e) {
System.err.println(e.getMessage());
System.err.println();
jcommander.usage();
return false;
}
String cmd = jcommander.getParsedCommand();
if (cmd == null) {
jcommander.usage();
return false;
} else {
JCommander obj = jcommander.getCommands().get(cmd);
CliCommand cmdObj = (CliCommand) obj.getObjects().get(0);
try {
cmdObj.run();
return true;
} catch (ParameterException e) {
System.err.println(e.getMessage());
System.err.println();
jcommander.usage();
return false;
} catch (ConnectException e) {
System.err.println(e.getMessage());
System.err.println();
System.err.println("Error connecting to: " + admin.getServiceUrl());
return false;
} catch (PulsarAdminException e) {
System.err.println(e.getHttpError());
System.err.println();
System.err.println("Reason: " + e.getMessage());
return false;
} catch (Exception e) {
System.err.println("Got exception: " + e.getMessage());
e.printStackTrace();
return false;
}
}
}
Aggregations