Search in sources :

Example 1 with ConnectException

use of com.yahoo.pulsar.client.admin.PulsarAdminException.ConnectException in project pulsar by yahoo.

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(com.yahoo.pulsar.client.admin.PulsarAdminException) ParameterException(com.beust.jcommander.ParameterException) ConnectException(com.yahoo.pulsar.client.admin.PulsarAdminException.ConnectException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ConnectException(com.yahoo.pulsar.client.admin.PulsarAdminException.ConnectException)

Aggregations

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