List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.elasticsearch.client.SyncResponseListenerTests.java
public void testExceptionIsWrapped() throws Exception { RestClient.SyncResponseListener syncResponseListener = new RestClient.SyncResponseListener(10000); //we just need any checked exception URISyntaxException exception = new URISyntaxException("test", "test"); syncResponseListener.onFailure(exception); try {//from w w w . ja va2 s .c om syncResponseListener.get(); fail("get should have failed"); } catch (RuntimeException e) { assertEquals("error while performing request", e.getMessage()); assertSame(exception, e.getCause()); } }
From source file:no.digipost.api.useragreements.client.ApiService.java
public EntryPoint getEntryPoint() { try {//from w ww .ja v a2s . c o m return cachedEntryPoint.get(); } catch (RuntimeException e) { if (e.getCause() instanceof UserAgreementsApiException) { throw (UserAgreementsApiException) e.getCause(); } else { throw e; } } }
From source file:org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil.java
/** * Validate input logic./*from ww w . j a va 2s.c o m*/ * * @throws JDOMException the JDOM exception * @throws CommandException */ public void validateInputLogic() throws JDOMException, CommandException { JexlEngine jexl = new OozieJexlEngine(); String expression = CoordUtils.getInputLogic(coordAction.getActionXml().toString()); if (StringUtils.isEmpty(expression)) { return; } Expression e = jexl.createExpression(expression); JexlContext jc = new OozieJexlParser(jexl, new CoordInputLogicBuilder(new CoordInputLogicEvaluatorPhaseValidate(coordAction))); try { Object result = e.evaluate(jc); log.debug("Input logic expression is [{0}] and evaluate result is [{1}]", expression, result); } catch (RuntimeException re) { throw new CommandException(ErrorCode.E1028, re.getCause().getMessage()); } }
From source file:org.pentaho.di.trans.dataservice.streaming.execution.StreamingGeneratedTransExecution.java
@VisibleForTesting protected void waitForGeneratedTransToFinnish() { try {/* ww w . j a v a 2s . c o m*/ genTrans.waitUntilFinished(); } catch (RuntimeException e) { if (e.getCause() instanceof InterruptedException) { logger.debug( "The generated transformation was stopped, which resulted in an interruption of the generated transformation wait until finished call"); //this is normal if the transformation is terminated while we are waiting for it to finnish } else { throw new RuntimeException(e); } } }
From source file:org.metaborg.intellij.idea.parsing.annotations.MetaborgSourceAnnotator.java
@Nullable @Override//from w w w . ja v a2 s . c om public ISpoofaxAnalyzeUnit doAnnotate(final MetaborgSourceAnnotationInfo info) { this.logger.debug("Requesting analysis result for file: {}", info.resource()); @Nullable ISpoofaxAnalyzeUnit analysisResult = null; try { final IContext context = info.context(); final ISpoofaxInputUnit input = unitSerivce.inputUnit(info.resource(), info.text(), context.language(), null); analysisResult = this.analysisResultProcessor.request(input, context).toBlocking().single(); } catch (final RuntimeException ex) { // FIXME: Dedicated exception! if (ex.getCause() instanceof AnalysisException && ex.getCause().getMessage().equals("No analysis results.")) { this.logger.info("No analysis results for file: {}", info.resource()); } else { this.logger.error("Runtime exception while annotating file: {}", ex, info.resource()); } } this.logger.info("Requested analysis result for file: {}", info.resource()); return analysisResult; }
From source file:com.gisgraphy.fulltext.FullTextSearchEngine.java
public void executeAndSerialize(FulltextQuery query, OutputStream outputStream) throws FullTextSearchException { statsUsageService.increaseUsage(StatsUsageType.FULLTEXT); Assert.notNull(query, "Can not execute a null query"); Assert.notNull(outputStream, "Can not serialize into a null outputStream"); String queryString = ZipcodeNormalizer.normalize(query.getQuery(), query.getCountryCode()); query.withQuery(queryString);//from w ww. j a va2 s . c o m try { if (!disableLogging) { logger.info(query.toString()); } ModifiableSolrParams params = FulltextQuerySolrHelper.parameterize(query); CommonsHttpSolrServer server = new CommonsHttpSolrServer(solrClient.getURL(), this.httpClient, new OutputstreamResponseWrapper(outputStream, params.get(Constants.OUTPUT_FORMAT_PARAMETER))); server.query(params); } catch (SolrServerException e) { logger.error("Can not execute query " + FulltextQuerySolrHelper.toQueryString(query) + "for URL : " + solrClient.getURL() + " : " + e.getCause().getMessage(), e); throw new FullTextSearchException(e.getCause().getMessage()); } catch (MalformedURLException e1) { logger.error("The URL " + solrClient.getURL() + " is incorrect", e1); throw new FullTextSearchException(e1); } catch (RuntimeException e2) { String message = e2.getCause() != null ? e2.getCause().getMessage() : e2.getMessage(); logger.error("An error has occurred during fulltext search of query " + query + " : " + message, e2); throw new FullTextSearchException(message, e2); } }
From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java
private void evaluateType(ICoReTypeName type, List<ProjectUsageStore> usageStores) throws IOException { Set<ProjectIdentifier> projects = usageStores.stream().flatMap(store -> store.getProjects(type).stream()) .collect(Collectors.toSet()); if (projects.size() < numFolds) { ++skippedNumProjects;/*from w ww . j av a2 s . c om*/ return; } log("%s:\n", CoReNames.vm2srcQualifiedType(type)); List<List<ProjectIdentifier>> projectFolds = createProjectFolds(projects, type, usageStores); List<EvaluationResult> localResults = new ArrayList<>(usageStores.size() * usageStores.size()); for (ProjectUsageStore trainingStore : usageStores) { Map<ProjectIdentifier, List<Usage>> trainingUsages = loadUsages(trainingStore, type); for (ProjectUsageStore validationStore : usageStores) { // avoid unnecessary loading of usages Map<ProjectIdentifier, List<Usage>> validationUsages = (trainingStore == validationStore) ? trainingUsages : loadUsages(validationStore, type); ProjectTrainValidateSetProvider setProvider = new ProjectTrainValidateSetProvider(projectFolds, trainingUsages, validationUsages); double score; try { score = cvEvaluator.evaluate(setProvider); localResults.add(new EvaluationResult(trainingStore.getName(), validationStore.getName(), score, getNumberOfUsages(trainingUsages), getNumberOfUsages(validationUsages))); } catch (RuntimeException e) { if (e.getCause() instanceof EmptySetException) { ++skippedUsageFilter; return; } else { throw e; } } log("\t%s-%s: %s=%.3f, Fold size deviation=%.1f\n", trainingStore.getName(), validationStore.getName(), cvEvaluator.getMeasure().getClass().getSimpleName(), score, setProvider.getAbsoluteFoldSizeDeviation()); } } results.put(type, localResults); }
From source file:com.opengamma.util.db.management.HSQLDbManagement.java
@Override public void dropSchema(String catalog, String schema) { try {/* w w w . ja v a2 s.c om*/ super.dropSchema(catalog, schema); } catch (RuntimeException ex) { // try deleting database if (ex.getCause() instanceof SQLInvalidAuthorizationSpecException) { FileUtils.deleteQuietly(getFile()); super.dropSchema(catalog, schema); } } /* * NOTE jonathan 2013-04-11 -- this should work but for some reason doesn't Connection conn = null; try { if (!getCatalogCreationStrategy().catalogExists(catalog)) { System.out.println("Catalog " + catalog + " does not exist"); return; // nothing to drop } conn = connect(catalog); if (schema == null) { schema = "PUBLIC"; } Statement statement = conn.createStatement(); statement.executeUpdate("DROP SCHEMA " + schema + " CASCADE"); statement.close(); } catch (SQLException e) { throw new OpenGammaRuntimeException("Failed to drop schema", e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException e) { } } */ }
From source file:org.apache.qpid.server.virtualhost.VirtualHostImplTest.java
/** * Tests that specifying an unknown exchange to bind the queue to results in failure to create the vhost *///from w ww . ja va2s . co m public void testSpecifyingUnknownExchangeThrowsException() throws Exception { final String queueName = getName(); final String exchangeName = "made-up-exchange"; File config = writeConfigFile(queueName, queueName, exchangeName, true, new String[0]); try { createVirtualHost(queueName, config); fail("virtualhost creation should have failed due to illegal configuration"); } catch (RuntimeException e) { assertNotNull(e.getCause()); assertEquals(ConfigurationException.class, e.getCause().getClass()); Throwable configException = e.getCause(); assertEquals("Attempt to bind queue '" + queueName + "' to unknown exchange:" + exchangeName, configException.getMessage()); } }
From source file:org.neo4j.harness.InProcessBuilderTest.java
@Test public void shouldFailWhenProvidingANonDirectoryAsSource() throws IOException { File notADirectory = File.createTempFile("prefix", "suffix"); assertFalse(notADirectory.isDirectory()); try (ServerControls ignored = newInProcessBuilder().copyFrom(notADirectory).newServer()) { fail("server should not start"); } catch (RuntimeException rte) { Throwable cause = rte.getCause(); assertTrue(cause instanceof IOException); assertTrue(cause.getMessage().contains("exists but is not a directory")); }//from w w w . j a v a 2s . c o m }