Example usage for java.lang Throwable getMessage

List of usage examples for java.lang Throwable getMessage

Introduction

In this page you can find the example usage for java.lang Throwable getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:eu.stratosphere.pact.client.WebFrontend.java

/**
 * Main method. accepts a single parameter, which is the config directory.
 * //from w ww  .j  ava 2  s  .  c o m
 * @param args
 *        The parameters to the entry point.
 */
public static void main(String[] args) {
    try {
        // get the config directory first
        String configDir = null;

        if (args.length >= 2 && args[0].equals("-configDir")) {
            configDir = args[1];
        }

        if (configDir == null) {
            System.err.println(
                    "Error: Configuration directory must be specified.\nWebFrontend -configDir <directory>\n");
            System.exit(1);
            return;
        }

        // load the global configuration
        GlobalConfiguration.loadConfiguration(configDir);
        Configuration config = GlobalConfiguration.getConfiguration();

        // add stratosphere base dir to config
        config.setString(PactConfigConstants.STRATOSPHERE_BASE_DIR_PATH_KEY, configDir + "/..");

        // get the listening port
        int port = config.getInteger(PactConfigConstants.WEB_FRONTEND_PORT_KEY,
                PactConfigConstants.DEFAULT_WEB_FRONTEND_PORT);

        // start the server
        WebInterfaceServer server = new WebInterfaceServer(config, port);
        LOG.info("Starting web frontend server on port " + port + '.');
        server.start();
        server.join();
    } catch (Throwable t) {
        LOG.error("Unexpected exception: " + t.getMessage(), t);
    }
}

From source file:com.ms.commons.standalone.job.JobRunner.java

public static void main(String[] args) throws JobExecutionException {
    logger.error("__start of job, args is " + StringUtils.join(args, ", "));
    // try and catch everything
    try {//from   w w w.j ava  2s .c  om
        checkArgs(args);
        JobAction jobAction = JobAction.valueOf(args[0].trim());
        String fullClassName = args[1].trim();
        String[] NewArgs = getNewArgs(args);

        AbstractJob job = getJobInstanceByClassName(fullClassName);
        job.setArgs(NewArgs);

        clearStandaloneStopFile();

        switch (jobAction) {
        case start:
            job.execute(null);
            break;
        case startNohup:
            job.execute(null);
            break;
        case startWithDebug:
            job.execute(null);
            break;
        case stop:
            stopJob();
            break;
        default:
            throw new RuntimeException("jobAction must be start or stop");
        }
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        t.printStackTrace();
    }
    logger.error("__end of job, args is " + StringUtils.join(args, ", "));
    System.exit(0);
}

From source file:be.i8c.sag.wm.is.SwaggerImporter.java

public static void main(String[] args) throws Exception {
    CommandLineParser parser = new DefaultParser();
    Options options = getOptions();//from w  w  w.j  av a 2  s .  c o m
    CommandLine cmd = parser.parse(options, args);
    HelpFormatter formatter = new HelpFormatter();
    if (cmd.hasOption("h")) {
        formatter.printHelp("", options);
    } else if (cmd.hasOption("is") && cmd.hasOption("u") && cmd.hasOption("p") && cmd.hasOption("swf")
            && cmd.hasOption("pkg")) {
        SwaggerParser swaggerParser = new SwaggerParser();
        Swagger swaggerModel = swaggerParser.read(cmd.getOptionValue("swf"));
        String[] conn = cmd.getOptionValue("is").split(":");
        String host = conn[0];
        String port = "80";
        if (conn.length > 1) {
            port = conn[1];
        }
        ServerConnection sc = new ServerConnection(host, port, cmd.getOptionValue("u"), cmd.getOptionValue("p"),
                false);
        try {
            logger.info("Connecting to server " + host + "(" + port + ")");
            sc.connect();
            logger.info("Connected to server");

            RestImplementation ri = new RestImplementation(sc, swaggerModel, cmd.getOptionValue("pkg"),
                    cmd.getOptionValue("acl"));

            ri.generateImplementation();

        } catch (Throwable e) {
            logger.error("Error: " + e.getMessage());
            //logger.error(e.getStackTrace());
            e.printStackTrace();
        } finally {
            logger.info("Disconnecting from server");
            sc.disconnect();
            ServerConnectionManager.getInstance().closeServerConnectionManager();
            logger.info("Disconnected from server");
            logger.info("BYE");
            System.exit(0);
        }
    }

}

From source file:com.espertech.esper.example.servershellclient.ServerShellClientMain.java

public static void main(String[] args) throws Exception {
    try {/*from   w w w  .j  ava  2 s .c  om*/
        new ServerShellClientMain();
    } catch (Throwable t) {
        log.error("Error starting server shell client : " + t.getMessage(), t);
        System.exit(-1);
    }
}

From source file:it.cnr.icar.eric.client.admin.AdminShellUtilityTest.java

public static void main(String[] args) {
    try {//from w w w.j  av a  2 s .c o m
        junit.textui.TestRunner.run(suite());
    } catch (Throwable t) {
        System.out.println("Throwable: " + t.getClass().getName() + " Message: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:it.cnr.icar.eric.client.xml.registry.SecureSessionPerformanceTest.java

public static void main(String[] args) {
    System.out.println("Get into the program...\n");
    try {/*from   w  ww . java  2  s.  c  om*/
        TestRunner.run(suite());
    } catch (Throwable t) {
        System.out.println("Throwable: " + t.getClass().getName() + " Message: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:com.espertech.esper.example.servershell.ServerShellMain.java

public static void main(String[] args) throws Exception {
    try {/*from w  w  w  .j ava2  s.c o  m*/
        new ServerShellMain();
    } catch (Throwable t) {
        log.error("Error starting server shell : " + t.getMessage(), t);
        System.exit(-1);
    }
}

From source file:grails.util.GenerateUtils.java

public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        return;//from   www .j  av  a 2  s.c  o m
    }

    String type = args[0];
    String domainClassName = args[1];

    ApplicationContext parent = new ClassPathXmlApplicationContext("applicationContext.xml");
    GrailsApplication application = parent.getBean("grailsApplication", DefaultGrailsApplication.class);

    GrailsDomainClass domainClass = findInApplication(application, domainClassName);

    // bootstrap application to try hibernate domain classes
    if (domainClass == null) {
        GrailsRuntimeConfigurator config = new GrailsRuntimeConfigurator(application, parent);
        config.configure(new MockServletContext());
    }

    // retry
    domainClass = findInApplication(application, domainClassName);
    if (domainClass == null) {
        LOG.info("Unable to generate [" + type + "] domain class not found for name [" + domainClassName + "]");
        System.exit(0);
    }

    try {
        GroovyClassLoader gcl = new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
        GrailsTemplateGenerator generator = (GrailsTemplateGenerator) gcl.parseClass(
                gcl.getResourceAsStream(
                        "org/codehaus/groovy/grails/scaffolding/DefaultGrailsTemplateGenerator.groovy"),
                "DefaultGrailsTemplateGenerator.groovy").newInstance();
        if (!CONTROLLER.equals(type) && !VIEWS.equals(type) && !ALL.equals(type)) {
            LOG.info("Grails was unable to generate templates for unsupported type [" + type + "]");
        } else {
            if (VIEWS.equals(type) || ALL.equals(type)) {
                LOG.info("Generating views for domain class [" + domainClass.getName() + "]");
                generator.generateViews(domainClass, ".");
            }
            if (CONTROLLER.equals(type) || ALL.equals(type)) {
                LOG.info("Generating controller for domain class [" + domainClass.getName() + "]");
                generator.generateController(domainClass, ".");
            }
        }
    } catch (Throwable t) {
        LOG.info("Error during code generation: " + t.getMessage());
        LOG.error(t.getMessage(), t);
    } finally {
        System.exit(0);
    }
}

From source file:mjc.ARMMain.java

public static void main(String[] args) {

    for (String arg : args) {
        if (!arg.startsWith("-")) { // ignore flags
            try {
                File in = new File(arg);
                File out = new File(FilenameUtils.removeExtension(in.getName()) + ".s");
                compile(new FileInputStream(in), new PrintStream(out));
            } catch (FileNotFoundException e) {
                System.err.println("Error: " + e.getMessage());
                System.exit(1);/* w  w  w  .  j  a  v a2s  . c  o m*/
            } catch (Throwable t) {
                System.err.println("Could not compile: " + t.getMessage());
                System.exit(1);
            }
        }
    }

    // All went well, exit with status 0.
    System.exit(0);

}

From source file:Deet.java

public static void main(String... args) {
    if (args.length != 4) {
        err.format("Usage: java Deet <classname> <langauge> <country> <variant>%n");
        return;/*w  w  w . j a  v a 2s  .  c o m*/
    }

    try {
        Class<?> c = Class.forName(args[0]);
        Object t = c.newInstance();

        Method[] allMethods = c.getDeclaredMethods();
        for (Method m : allMethods) {
            String mname = m.getName();
            if (!mname.startsWith("test") || (m.getGenericReturnType() != boolean.class)) {
                continue;
            }
            Type[] pType = m.getGenericParameterTypes();
            if ((pType.length != 1) || Locale.class.isAssignableFrom(pType[0].getClass())) {
                continue;
            }

            out.format("invoking %s()%n", mname);
            try {
                m.setAccessible(true);
                Object o = m.invoke(t, new Locale(args[1], args[2], args[3]));
                out.format("%s() returned %b%n", mname, (Boolean) o);

                // Handle any exceptions thrown by method to be invoked.
            } catch (InvocationTargetException x) {
                Throwable cause = x.getCause();
                err.format("invocation of %s failed: %s%n", mname, cause.getMessage());
            }
        }

        // production code should handle these exceptions more gracefully
    } catch (ClassNotFoundException x) {
        x.printStackTrace();
    } catch (InstantiationException x) {
        x.printStackTrace();
    } catch (IllegalAccessException x) {
        x.printStackTrace();
    }
}