Search in sources :

Example 1 with ConnectException

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;
        }
    }
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) ConnectException(org.apache.pulsar.client.admin.PulsarAdminException.ConnectException) ParameterException(com.beust.jcommander.ParameterException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) ConnectException(org.apache.pulsar.client.admin.PulsarAdminException.ConnectException)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)1 ConnectException (org.apache.pulsar.client.admin.PulsarAdminException.ConnectException)1