List of usage examples for java.lang Throwable getLocalizedMessage
public String getLocalizedMessage()
From source file:caarray.client.test.suite.ConfigurableTestSuite.java
/** * Loads and executes all of the test cases encapsulated in this suite, and * adds the test results to the given TestResultReport. The tests may be created * via input from a configuration file, but may also include tests determined * by other means.//from w w w. j a v a 2 s . co m * * @param resultReport The TestResultReport to which test results will be added. */ public void runTests(TestResultReport resultReport) { try { loadTestsFromFile(); executeTests(resultReport); } catch (FileNotFoundException e) { String errorMessage = "An error occured reading an " + getType() + " configuration file: " + e.getMessage(); resultReport.addErrorMessage(errorMessage); e.printStackTrace(); log.error("Exception encountered:", e); } catch (IOException e) { String errorMessage = "An error occured executing the " + getType() + " test suite: " + e.getMessage(); resultReport.addErrorMessage(errorMessage); e.printStackTrace(); log.error("Exception encountered:", e); } catch (TestConfigurationException e) { String errorMessage = "An error occured executing the " + getType() + " test suite, probably due to an error in the configuration " + "file: " + e.getMessage(); resultReport.addErrorMessage(errorMessage); e.printStackTrace(); log.error("Exception encountered:", e); } catch (Throwable t) { String errorMessage = "An unexpected error occured executing the " + getType() + " : " + t.getLocalizedMessage(); resultReport.addErrorMessage(errorMessage); t.printStackTrace(); log.error("Exception encountered:", t); } }
From source file:org.kalypso.model.wspm.tuhh.schema.simulation.MultipleRunoffReader.java
public void readPolynomeResults(final File polynomeTmpDir, final File resultDir, final LogHelper log, final ISimulationResultEater resultEater) throws SimulationException { try {/*from w ww. j a v a2 s. c o m*/ final QIntervalReader qIntervalReader = new QIntervalReader(resultDir, m_intervalIndex, log); qIntervalReader.execute(new NullProgressMonitor()); } catch (final Throwable e) { log.log(e, Messages.getString("org.kalypso.model.wspm.tuhh.schema.simulation.PolynomeProcessor.14"), //$NON-NLS-1$ e.getLocalizedMessage()); final ISimulationMonitor monitor = log.getMonitor(); monitor.setFinishInfo(IStatus.ERROR, Messages.getString("org.kalypso.model.wspm.tuhh.schema.simulation.PolynomeProcessor.15") //$NON-NLS-1$ + e.getLocalizedMessage()); } final File polynomeLogFile = new File(polynomeTmpDir, "Polynome1d.log"); //$NON-NLS-1$ if (polynomeLogFile.exists()) resultEater.addResult("polynomeLog", polynomeLogFile); //$NON-NLS-1$ }
From source file:org.jolokia.http.HttpRequestHandler.java
private String getExceptionMessage(Throwable pException) { String message = pException.getLocalizedMessage(); return pException.getClass().getName() + (message != null ? " : " + message : ""); }
From source file:org.geotools.utils.progress.BaseArgumentsManager.java
public boolean parseArgs(String[] args) { cmdLine = cmdParser.parseAndHelp(args); if (cmdLine == null) return false; if (cmdLine.hasOption(versionOpt)) { System.out.print(new StringBuffer(getToolName()).append(" - GeoSolutions S.a.s (C) 2006 - v") .append(getVersion()).toString()); System.exit(0);//from w w w. j ava 2 s .c o m } // // // // Tile cache size // // // // index name if (cmdLine.hasOption(tileCacheSizeOpt)) try { tileCacheSize = Integer.parseInt((String) cmdLine.getValue(tileCacheSizeOpt)); } catch (Throwable e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return false; } // // // // Thread priority // // // // index name if (cmdLine.hasOption(priorityOpt)) try { priority = Integer.parseInt((String) cmdLine.getValue(priorityOpt)); } catch (Throwable e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return false; } setJAIHints(); return true; }
From source file:org.polymap.core.data.imex.FileUploadPage.java
protected void parseData(InputStream in) { setMessage(null);/*from ww w .j a v a2 s . c om*/ try { features = ((FileImportWizard) getWizard()).parseKml(in); updateFeaturesViewer(); checkFinish(); } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); log.warn(i18n.get("uploadError", rootCause.getLocalizedMessage()), e); setMessage(i18n.get("uploadError", rootCause.getLocalizedMessage()), DialogPage.ERROR); } finally { IOUtils.closeQuietly(in); } }
From source file:org.polymap.core.catalog.model.CatalogImpl.java
/** * Fire a resource changed event, these may be batched into one delta for * performance./*from w ww . j ava 2 s . com*/ */ public void fire(IResolveChangeEvent event) { for (Object listener : catalogListeners.getListeners()) { try { ((IResolveChangeListener) listener).changed(event); } catch (Throwable e) { PolymapWorkbench.handleError(CatalogPlugin.PLUGIN_ID, this, e.getLocalizedMessage(), e); } } }
From source file:com.chessix.vas.web.AccountController.java
@RequestMapping(value = "/{clasId}/{accountId}", method = RequestMethod.POST) public DeferredResult<Object> createAccount(@PathVariable final String clasId, @PathVariable final String accountId) { log.info("createAccount({},{})", clasId, accountId); final ActorRef clas = clasService.getClas(clasId); final DeferredResult<Object> deferredResult = new DeferredResult<Object>(); if (clas != null) { final Future<Object> future = Patterns.ask(clas, new CreateAccount.RequestBuilder(clasId).accountId(accountId).build(), timeout); future.onSuccess(new OnSuccess<Object>() { @Override//from w w w .j a v a2 s. com public void onSuccess(final Object result) { log.info("createAccount({}) : result: {}", clasId, result); final CreateAccount.Response response = (CreateAccount.Response) result; deferredResult.setResult( new AccountCreated(clasId, response.getAccountId(), true, "Account created")); } }, system.dispatcher()); future.onFailure(new OnFailure() { @Override public void onFailure(final Throwable arg) throws Throwable { log.error("onFailure", arg); deferredResult .setErrorResult(new AccountCreated(clasId, null, false, arg.getLocalizedMessage())); } }, system.dispatcher()); } else { deferredResult.setErrorResult(new AccountCreated(clasId, null, false, "CLAS does not exist")); } return deferredResult; }
From source file:it.geosolutions.tools.io.file.FileRemover.java
/** * This method does the magic:/*from w w w . j a va 2s. c om*/ * * <ol> * <li>iterate over all the files</li> * <li>try to delete it</li> * <li>if successful drop the file references</li> * <li>if not successful increase the attempts count for the file and call * the gc. If the maximum number was exceeded drop the file and warn the * user</li> * */ public void run() { while (true) { try { synchronized (FILES_PATH) { synchronized (FILE_ATTEMPTS_COUNTS) { final Iterator<String> it = FILES_PATH.iterator(); while (it.hasNext()) { // get next file path and its count final String sFile = it.next(); if (LOGGER.isInfoEnabled()) LOGGER.info("Trying to remove file " + sFile); int attempts = FILE_ATTEMPTS_COUNTS.get(sFile).intValue(); if (!new File(sFile).exists()) { it.remove(); FILE_ATTEMPTS_COUNTS.remove(sFile); } else { // try to delete it if (new File(sFile).delete()) { if (LOGGER.isInfoEnabled()) LOGGER.info("Successfully removed file " + sFile); it.remove(); FILE_ATTEMPTS_COUNTS.remove(sFile); } else { if (LOGGER.isInfoEnabled()) LOGGER.info("Unable to remove file " + sFile); attempts++; if (maxAttempts < attempts) { if (LOGGER.isInfoEnabled()) LOGGER.info("Dropping file " + sFile); it.remove(); FILE_ATTEMPTS_COUNTS.remove(sFile); if (LOGGER.isWarnEnabled()) LOGGER.warn("Unable to delete file " + sFile); } else { FILE_ATTEMPTS_COUNTS.remove(sFile); FILE_ATTEMPTS_COUNTS.put(sFile, new Integer(attempts)); // might help, see // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); System.runFinalization(); System.runFinalization(); System.runFinalization(); System.runFinalization(); System.runFinalization(); System.runFinalization(); } } } } } } Thread.sleep(period * 1000); } catch (Throwable t) { if (LOGGER.isInfoEnabled()) LOGGER.info(t.getLocalizedMessage(), t); } } }
From source file:com.nts.alphamale.handler.FollowerHandler.java
/*** * ??? record ?? /*from w w w . j a v a2s. c om*/ * @param job */ @Subscribe @AllowConcurrentEvents public void task(Job job) { Job rjob = null; try { rjob = (Job) job.clone(); if (isLeader == false) { if (rjob.getJobType() == JobType.POSITION_BASE) { rjob.convertPoint(deviceInfo); } } else { return; } Object rsltObj = client.invoke(rjob); if (rsltObj instanceof Boolean) { boolean isSuccess = (Boolean) rsltObj; ExecutionLogManager.add(rjob.getSeq(), rjob.getTitle(), serial, deviceInfo.getModel(), isSuccess, "unknown"); } } catch (Throwable e) { log.info("Exception Follower(" + deviceInfo.getModel() + ") - " + e.getStackTrace()); ExecutionLogManager.add(rjob.getSeq(), rjob.getTitle(), serial, deviceInfo.getModel(), false, e.getLocalizedMessage()); } finally { ExecutionLogManager.send(rjob.getSeq(), false); } }