List of usage examples for java.lang Throwable toString
public String toString()
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Throwable(); System.out.println(t.toString()); }
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Throwable("from java2s.com"); System.out.println(t.toString()); }
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); System.out.println(t.toString()); }
From source file:eu.itesla_project.online.mpi.Master.java
public static void main(String[] args) throws Exception { try {//w w w . ja v a 2s.c om CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(OPTIONS, args); String mode = line.getOptionValue("m"); Path tmpDir = Paths.get(line.getOptionValue("t")); Class<?> statisticsFactoryClass = Class.forName(line.getOptionValue("f")); Path statisticsDbDir = Paths.get(line.getOptionValue("s")); String statisticsDbName = line.getOptionValue("d"); int coresPerRank = Integer.parseInt(line.getOptionValue("n")); Path stdOutArchive = line.hasOption("o") ? Paths.get(line.getOptionValue("o")) : null; MpiExecutorContext mpiExecutorContext = new MultiStateNetworkAwareMpiExecutorContext(); ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1); ExecutorService executorService = MultiStateNetworkAwareExecutors.newCachedThreadPool(); try { MpiStatisticsFactory statisticsFactory = statisticsFactoryClass .asSubclass(MpiStatisticsFactory.class).newInstance(); MpiStatistics statistics = statisticsFactory.create(statisticsDbDir, statisticsDbName); try (ComputationManager computationManager = new MpiComputationManager(tmpDir, statistics, mpiExecutorContext, coresPerRank, false, stdOutArchive)) { OnlineConfig config = OnlineConfig.load(); try (LocalOnlineApplication application = new LocalOnlineApplication(config, computationManager, scheduledExecutorService, executorService, true)) { switch (mode) { case "ui": System.out.println("LocalOnlineApplication created"); System.out.println("Waiting till shutdown"); // indefinitely wait for JMX commands //TimeUnit.DAYS.sleep(Integer.MAX_VALUE); synchronized (application) { try { application.wait(); } catch (InterruptedException ex) { } } break; default: throw new IllegalArgumentException("Invalid mode " + mode); } } } } finally { mpiExecutorContext.shutdown(); executorService.shutdown(); scheduledExecutorService.shutdown(); executorService.awaitTermination(15, TimeUnit.MINUTES); scheduledExecutorService.awaitTermination(15, TimeUnit.MINUTES); } } catch (ParseException e) { System.err.println(e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("master", OPTIONS, true); System.exit(-1); } catch (Throwable t) { LOGGER.error(t.toString(), t); System.exit(-1); } }
From source file:eu.itesla_project.offline.mpi.Master.java
public static void main(String[] args) throws Exception { try {// w ww.jav a 2s . c o m CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(OPTIONS, args); Mode mode = Mode.valueOf(line.getOptionValue("mode")); String simulationDbName = line.hasOption("simulation-db-name") ? line.getOptionValue("simulation-db-name") : OfflineConfig.DEFAULT_SIMULATION_DB_NAME; String rulesDbName = line.hasOption("rules-db-name") ? line.getOptionValue("rules-db-name") : OfflineConfig.DEFAULT_RULES_DB_NAME; String metricsDbName = line.hasOption("metrics-db-name") ? line.getOptionValue("metrics-db-name") : OfflineConfig.DEFAULT_METRICS_DB_NAME; Path tmpDir = Paths.get(line.getOptionValue("tmp-dir")); Class<?> statisticsFactoryClass = Class.forName(line.getOptionValue("statistics-factory-class")); Path statisticsDbDir = Paths.get(line.getOptionValue("statistics-db-dir")); String statisticsDbName = line.getOptionValue("statistics-db-name"); int coresPerRank = Integer.parseInt(line.getOptionValue("cores")); Path stdOutArchive = line.hasOption("stdout-archive") ? Paths.get(line.getOptionValue("stdout-archive")) : null; String workflowId = line.hasOption("workflow") ? line.getOptionValue("workflow") : null; MpiExecutorContext mpiExecutorContext = new MultiStateNetworkAwareMpiExecutorContext(); ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1); ExecutorService offlineExecutorService = MultiStateNetworkAwareExecutors .newSizeLimitedThreadPool("OFFLINE_POOL", 100); try { MpiStatisticsFactory statisticsFactory = statisticsFactoryClass .asSubclass(MpiStatisticsFactory.class).newInstance(); try (MpiStatistics statistics = statisticsFactory.create(statisticsDbDir, statisticsDbName)) { try (ComputationManager computationManager = new MpiComputationManager(tmpDir, statistics, mpiExecutorContext, coresPerRank, false, stdOutArchive)) { OfflineConfig config = OfflineConfig.load(); try (LocalOfflineApplication application = new LocalOfflineApplication(config, computationManager, simulationDbName, rulesDbName, metricsDbName, scheduledExecutorService, offlineExecutorService)) { switch (mode) { case ui: application.await(); break; case simulations: { if (workflowId == null) { workflowId = application.createWorkflow(null, OfflineWorkflowCreationParameters.load()); } application.startWorkflowAndWait(workflowId, OfflineWorkflowStartParameters.load()); } break; case rules: { if (workflowId == null) { throw new RuntimeException("Workflow '" + workflowId + "' not found"); } application.computeSecurityRulesAndWait(workflowId); } break; default: throw new IllegalArgumentException("Invalid mode " + mode); } } } } } finally { mpiExecutorContext.shutdown(); offlineExecutorService.shutdown(); scheduledExecutorService.shutdown(); offlineExecutorService.awaitTermination(15, TimeUnit.MINUTES); scheduledExecutorService.awaitTermination(15, TimeUnit.MINUTES); } } catch (ParseException e) { System.err.println(e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("master", OPTIONS, true); System.exit(-1); } catch (Throwable t) { LOGGER.error(t.toString(), t); System.exit(-1); } }
From source file:UnitTest4.java
public static void main(String args[]) { System.setProperty("org.slf4j.simpleLogger.showDateTime", "true"); System.setProperty("org.slf4j.simpleLogger.showThreadName", "true"); System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true"); System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss:SSS Z"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); System.setProperty("org.slf4j.simpleLogger.showLogName", "true"); final Logger log = LoggerFactory.getLogger(UnitTest4.class); UnitTest4.log = log;/*from w w w. j a va 2s.c om*/ System.out.println("hdfjkv \'dfdgdf\'dgdf"); try { throw new Exception(); } catch (Throwable e) { log.debug(e.toString()); //log.debug(" Cause : " + e.getCause().toString()); StackTraceElement stacka[] = e.getStackTrace(); for (StackTraceElement stack : stacka) { log.debug(" StackTrace : " + stack.toString()); } } String a[] = new String[10]; a[0] = "hwedf"; a[6] = "wdeeg"; log.debug("a.toString() : {}", a.toString()); /* List<Integer> list = new ArrayList<Integer>(); for (Integer i : list) { System.out.println(i); } System.out.println("ok"); try { //Test2.execute(); } catch (Exception e) { e.printStackTrace(); } */ }
From source file:es.sistedes.handle.generator.CliLauncher.java
public static void main(String[] args) { try {/* www .ja v a 2 s . com*/ run(args); } catch (Throwable t) { if (t instanceof RuntimeException || t instanceof Error) { // Log unexpected unchecked exception LOGGER.log(Level.SEVERE, t.toString(), t); } System.exit(ReturnCodes.ERROR.getReturnCode()); } }
From source file:es.emergya.Main.java
/** * Starts the app./*from w w w. ja va 2 s . c o m*/ * * @param args */ public static void main(final String[] args) { try { Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { if (LOG.isTraceEnabled()) { LOG.trace("Excepcion descontrolada en " + t.toString(), e); } else { LOG.error("Excepcion descontrolada en " + t.toString() + " :: " + e.toString(), e); } } }); } catch (Throwable t) { LOG.error(t, t); } try { TimeZone.setDefault(TimeZone.getTimeZone("Europe/Madrid")); //$NON-NLS-1$ new Initializer().run(); } catch (Throwable t) { LOG.error("Fallo el SwingUtilities.invokeLater", t); } }
From source file:com.bazaarvoice.jsonpps.PrettyPrintJson.java
public static void main(String[] args) throws Exception { try {/*from ww w.j a v a 2 s . co m*/ ArgumentParser parser = ArgumentParsers.newArgumentParser("jsonpps") .description("A streaming JSON pretty printer that can format multi-GB input files.") .defaultHelp(true); parser.addArgument("-o", "--out").type(Arguments.fileType()).setDefault(STDINOUT).help("output file"); parser.addArgument("--flatten").metavar("N").type(Integer.class).setDefault(0) .help("flatten the top-N levels of object/array structure"); parser.addArgument("-i", "--in-place").action(Arguments.storeTrue()) .help("modify the original file(s)"); parser.addArgument("-S", "--sort-keys").action(Arguments.storeTrue()).help( "emit objects with keys in sorted order. this increases memory requirements since objects must be buffered in memory."); parser.addArgument("--strict").action(Arguments.storeTrue()).help("reject non-conforming json"); parser.addArgument("--wrap").action(Arguments.storeTrue()).help("wrap all output in a json array"); parser.addArgument("--unwrap").action(Arguments.storeTrue()) .help("flatten the top level of object/array structure"); parser.addArgument("in").nargs("*") .type(Arguments.fileType().acceptSystemIn().verifyExists().verifyIsFile().verifyCanRead()) .setDefault(new File[] { STDINOUT }).help("input file(s)"); Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); System.exit(2); return; } PrettyPrintJson jsonpp = new PrettyPrintJson(); File outputFile = ns.get("out"); List<File> inputFiles = ns.getList("in"); boolean inPlace = ns.getBoolean("in_place"); jsonpp.setFlatten(ns.getInt("flatten")); jsonpp.setSortKeys(ns.getBoolean("sort_keys")); jsonpp.setStrict(ns.getBoolean("strict")); jsonpp.setWrap(ns.getBoolean("wrap")); if (ns.getBoolean("unwrap")) { jsonpp.setFlatten(1); } if (!inPlace) { // Pretty print all input files to a single output jsonpp.prettyPrint(inputFiles, outputFile); } else { // Pretty print all input files back to themselves. if (outputFile != STDINOUT) { // use "!=" not "!.equals()" since default is ok but "-o -" is not. System.err.println("error: -o and --in-place are mutually exclusive"); System.exit(2); } if (inputFiles.isEmpty()) { System.err.println("error: --in-place requires at least one input file"); System.exit(2); } if (inputFiles.contains(STDINOUT)) { System.err.println("error: --in-place cannot operate on stdin"); System.exit(2); } for (File inputFile : inputFiles) { jsonpp.prettyPrint(inputFile, inputFile); } } } catch (Throwable t) { t.printStackTrace(); System.err.println(t.toString()); System.exit(1); } }
From source file:com.googlecode.flyway.commandline.Main.java
/** * Main method.//from ww w . j a v a2 s .com * * @param args The command-line arguments. */ public static void main(String[] args) { boolean debug = isDebug(args); try { printVersion(); String operation = determineOperation(args); if (operation == null) { printUsage(); return; } loadJdbcDriversAndJavaMigrations(); Flyway flyway = new Flyway(); Properties properties = new Properties(); initializeDefaults(properties); loadConfigurationFile(properties, args); overrideConfiguration(properties, args); flyway.configure(properties); if ("clean".equals(operation)) { flyway.clean(); } else if ("init".equals(operation)) { flyway.init(); } else if ("migrate".equals(operation)) { flyway.migrate(); } else if ("validate".equals(operation)) { flyway.validate(); } else if ("status".equals(operation)) { MetaDataTableRowDumper.dumpMigration(flyway.status()); } else if ("history".equals(operation)) { MetaDataTableRowDumper.dumpMigrations(flyway.history()); } else { printUsage(); } } catch (Exception e) { if (debug) { LOG.error("Unexpected error", e); } else { LOG.error(ClassUtils.getShortName(e.getClass()) + ": " + e.getMessage()); outputFirstStackTraceElement(e); @SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" }) Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause != null) { LOG.error("Caused by " + rootCause.toString()); outputFirstStackTraceElement(rootCause); } } System.exit(1); } }