List of usage examples for java.lang RuntimeException getMessage
public String getMessage()
From source file:com.couchbase.spring.core.CouchbaseExceptionTranslator.java
/** * Translate Couchbase specific exceptions to spring exceptions if possible. * * @param ex the exception to translate. * @return the translated exception or null. *//*from w ww. j ava 2s .c o m*/ @Override public final DataAccessException translateExceptionIfPossible(RuntimeException ex) { if (ex instanceof ConnectionException) { return new DataAccessResourceFailureException(ex.getMessage(), ex); } if (ex instanceof ObservedException || ex instanceof ObservedTimeoutException || ex instanceof ObservedModifiedException) { return new DataIntegrityViolationException(ex.getMessage(), ex); } return null; }
From source file:org.jongo.CommandTest.java
@Test public void mustForceExceptionToBeThrownOnInvalidCommand() throws Exception { try {/*from ww w . jav a 2s. c o m*/ jongo.runCommand("{forceerror:1}").throwOnError().as(Validate.class); } catch (RuntimeException e) { assertThat(e.getMessage()).contains("errmsg"); } }
From source file:net.big_oh.resourcestats.web.filter.ResourceRequestStatsTrackerFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // capture time at which request was received Date requestReceivedOn = new Date(); // Time the operation at large Duration duration = new Duration(); // Carry on with the requested operation. chain.doFilter(request, response);/* w ww . j a v a 2s. c o m*/ // record resource access stats try { trackResourceRequestStats(request, requestReceivedOn, duration.stop()); } catch (RuntimeException re) { logger.error(re.getMessage(), re); } }
From source file:org.zenoss.zep.dao.impl.DaoUtilsTest.java
@Test public void testDeadlockRetryOtherException() throws Exception { final AtomicInteger i = new AtomicInteger(); try {/* w w w.j ava2 s .c o m*/ DaoUtils.deadlockRetry(new Callable<Integer>() { @Override public Integer call() throws Exception { i.incrementAndGet(); throw new RuntimeException("Bad exception - no retry"); } }); fail("Should have thrown an exception after first retry"); } catch (RuntimeException e) { assertEquals(1, i.get()); assertEquals("Bad exception - no retry", e.getMessage()); } }
From source file:alluxio.network.TieredIdentityFactoryTest.java
@Test public void notExecutable() throws Exception { File script = mFolder.newFile(); FileUtils.writeStringToFile(script, "#!/bin/bash"); try (Closeable c = new ConfigurationRule( ImmutableMap.of(PropertyKey.LOCALITY_SCRIPT, script.getAbsolutePath())).toResource()) { try {//from w ww .j a v a2 s. com TieredIdentity identity = TieredIdentityFactory.create(); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString(script.getAbsolutePath())); assertThat(e.getMessage(), containsString("Permission denied")); } } }
From source file:com.braindrainpain.docker.httpsupport.HttpClientServiceTest.java
@Test public void testCheckConnectionThrowsExceptionOnStatus404() throws IOException { when(httpClient.executeMethod(any(HttpMethod.class))).thenReturn(404); try {// w ww .j av a 2s . com httpClientService.checkConnection(URL); fail("RuntimeException expected if status is 404"); } catch (RuntimeException e) { Assert.assertEquals("Not ok from: '" + URL + "'", e.getMessage()); } }
From source file:com.espertech.esper.filter.ExprNodeAdapter.java
/** * Evaluate the boolean expression given the event as a stream zero event. * @param event is the stream zero event (current event) * @param exprEvaluatorContext context for expression evaluation * @return boolean result of the expression *//* w w w. j a v a2 s . co m*/ public boolean evaluate(EventBean event, ExprEvaluatorContext exprEvaluatorContext) { if (variableService != null) { variableService.setLocalVersion(); } EventBean[] eventsPerStream = arrayPerThread.get(); eventsPerStream[0] = event; try { Boolean result = (Boolean) exprNodeEval.evaluate(eventsPerStream, true, exprEvaluatorContext); if (result == null) { return false; } return result; } catch (RuntimeException ex) { log.error("Error evaluating expression '" + exprNode.toExpressionString() + "': " + ex.getMessage(), ex); return false; } }
From source file:com.threewks.thundr.bigmetrics.admin.BigMetricsQueryController.java
public JsonView queryResults(String queryId, Long pageSize, String pageToken) { try {/*from w w w . j a va 2 s. c o m*/ pageToken = StringUtils.trimToNull(pageToken); pageSize = clamp(pageSize, 1, 10000, 1000); boolean ready = bigMetricsService.isQueryComplete(queryId); if (!ready) { return new JsonView("Processing").withStatusCode(StatusCode.Accepted); } QueryResult queryResult = bigMetricsService.queryResult(queryId, pageSize, pageToken); return new JsonView(queryResult); } catch (RuntimeException e) { Logger.warn("Failed to check query results for job id %s: %s", queryId, e.getMessage()); return new JsonView("Failed " + e.getMessage()).withStatusCode(StatusCode.InternalServerError); } }
From source file:io.cloudslang.lang.compiler.modeller.TransformersHandler.java
private RuntimeException wrapErrorMessage(RuntimeException rex, String errorMessagePrefix) { return new RuntimeException(errorMessagePrefix + rex.getMessage(), rex); }
From source file:com.adeptj.modules.data.jpa.internal.EntityManagerFactoryLifecycle.java
@Activate protected void start(EntityManagerFactoryConfig config) { Validate.validState(this.repository != null, "JpaRepository must not be null!!"); String persistenceUnit = config.persistenceUnit(); Validate.isTrue(StringUtils.isNotEmpty(persistenceUnit), "PersistenceUnit name can't be empty!!"); Validate.validState(StringUtils.equals(this.repositoryPersistenceUnit, persistenceUnit), String.format(PU_NOT_MATCHED_EXCEPTION_MSG, this.repository, JPA_UNIT_NAME)); try {// w w w . j a v a 2s . c o m Map<String, Object> properties = JpaProperties.from(config); properties.put(NON_JTA_DATASOURCE, this.dataSourceService.getDataSource(config.dataSourceName())); ValidationMode validationMode = ValidationMode.valueOf(config.validationMode()); if (validationMode == AUTO || validationMode == CALLBACK) { properties.put(VALIDATOR_FACTORY, this.validatorService.getValidatorFactory()); } LOGGER.info("Creating EntityManagerFactory for PersistenceUnit: [{}]", persistenceUnit); // Note: The ClassLoader must be the one which loaded the given JpaRepository implementation // and it must have the visibility to the entity classes and persistence.xml/orm.xml // otherwise EclipseLink may not be able to create the EntityManagerFactory. properties.put(CLASSLOADER, this.repository.getClass().getClassLoader()); this.entityManagerFactory = new PersistenceProvider().createEntityManagerFactory(persistenceUnit, properties); this.repository.setEntityManagerFactory(new EntityManagerFactoryWrapper(this.entityManagerFactory)); LOGGER.info("Created EntityManagerFactory for PersistenceUnit: [{}]", persistenceUnit); } catch (RuntimeException ex) { // NOSONAR LOGGER.error(ex.getMessage(), ex); // Throw exception so that SCR won't register the component instance. throw new JpaBootstrapException(ex); } }