Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.thoughtworks.go.server.service.ServerConfigService.java

public void validateLdapSettings(LdapConfig ldapConfig, HttpLocalizedOperationResult result) {
    try {/*from  w  w  w. j  a v a2s .  c  o  m*/
        new LdapUserSearch(goConfigService, ldapContextSource(ldapConfig)).search(ANY_USER, ldapConfig);
    } catch (LdapUserSearch.NotAllResultsShownException ex) {
        // Connected to ldap sucessfully. Dont care about results.
    } catch (RuntimeException e) {
        result.connectionError(LocalizedMessage.string("CANNOT_CONNECT_TO_LDAP", e.getMessage()));
    }
}

From source file:com.thoughtworks.go.plugin.infra.monitor.DefaultExternalPluginJarLocationMonitorTest.java

@Test
void shouldThrowUpWhenExternalPluginDirectoryCreationFails() throws Exception {
    when(systemEnvironment.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn("/xyz");
    try {/*from  w ww.  java  2s.  c o  m*/
        new DefaultPluginJarLocationMonitor(systemEnvironment).initialize();
        fail("should have failed for missing external plugin folder");
    } catch (RuntimeException e) {
        assertThat(e.getMessage()).isEqualTo("Failed to create external plugins folder in location /xyz");
    }
}

From source file:io.druid.segment.realtime.firehose.WikipediaIrcDecoder.java

private DatabaseReader openDefaultGeoIpDb() {
    File geoDb = new File(System.getProperty("java.io.tmpdir"),
            this.getClass().getCanonicalName() + ".GeoLite2-City.mmdb");
    try {//from w  w  w  . j  a v a 2 s .c  o m
        return openDefaultGeoIpDb(geoDb);
    } catch (RuntimeException e) {
        log.warn(e.getMessage() + " Attempting to re-download.", e);
        if (geoDb.exists() && !geoDb.delete()) {
            throw new RuntimeException("Could not delete geo db file [" + geoDb.getAbsolutePath() + "].");
        }
        // local download may be corrupt, will retry once.
        return openDefaultGeoIpDb(geoDb);
    }
}

From source file:com.android.tests.lib.UnitTest.java

@Test
public void exceptions() {
    try {/* www  .  j  av a  2  s .  c om*/
        ArrayMap map = new ArrayMap();
        map.isEmpty();
        fail();
    } catch (RuntimeException e) {
        assertEquals(RuntimeException.class, e.getClass());
        assertTrue(e.getMessage().contains("isEmpty"));
        assertTrue(e.getMessage().contains("not mocked"));
        assertTrue(e.getMessage().contains("androidstudio/not-mocked"));
    }

    try {
        Debug.getThreadAllocCount();
        fail();
    } catch (RuntimeException e) {
        assertEquals(RuntimeException.class, e.getClass());
        assertTrue(e.getMessage().contains("getThreadAllocCount"));
        assertTrue(e.getMessage().contains("not mocked"));
        assertTrue(e.getMessage().contains("androidstudio/not-mocked"));
    }

}

From source file:com.espertech.esper.pattern.guard.ExpressionGuard.java

public boolean inspect(MatchedEventMap matchEvent) {
    EventBean[] eventsPerStream = convertor.convert(matchEvent);

    try {// w  w  w  .ja  v  a  2 s. c  om
        Object result = expression.evaluate(eventsPerStream, true,
                quitable.getContext().getAgentInstanceContext());
        if (result == null) {
            return false;
        }

        if (result.equals(Boolean.TRUE)) {
            return true;
        }

        quitable.guardQuit();
        return false;
    } catch (RuntimeException ex) {
        String message = "Failed to evaluate expression for pattern-guard for statement '"
                + quitable.getContext().getPatternContext().getStatementName() + "'";
        if (ex.getMessage() != null) {
            message += ": " + ex.getMessage();
        }
        log.error(message, ex);
        throw new EPException(message);
    }
}

From source file:com.predic8.membrane.client.core.controller.ServiceParamsManager.java

private void loadServiceParams() throws FileNotFoundException {
    List<WSDL> wsdls = config.getWsdls().getWSDLList();
    for (WSDL wsdl : wsdls) {
        Definitions definitions = null;/*from  w  ww  . j  ava  2s.  c o m*/
        try {
            definitions = SOAModelUtil.getDefinitions(wsdl.getUrl().getValue());
        } catch (RuntimeException e) {
            log.warn("Unable to get definitions for " + wsdl.getUrl() + ": " + e.getMessage());
        } finally {
            addNewServiceParams(new ServiceParams(wsdl.getUrl().getValue(), definitions), false);
        }
    }
}

From source file:com.thoughtworks.go.server.service.support.toggle.FeatureToggleRepositoryTest.java

@Test
public void shouldFailWhenUnableToWriteToUserTogglesFile_DuringChangingOfAToggleValue() throws Exception {
    setupAvailableToggles(new FeatureToggle("key1", "desc1", true));

    File userTogglesFile = setupUserToggles(new FeatureToggle("key1", "desc1", true));
    userTogglesFile.setReadOnly();//  ww  w . j  a  v a  2  s. c  om

    FeatureToggleRepository repository = new FeatureToggleRepository(environment);

    try {
        repository.changeValueOfToggle("key1", false);
        fail("Should have failed to write");
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), containsString(userTogglesFile.getPath()));
    }
}

From source file:com.bia.monitor.service.task.JobCheckImpl.java

/**
 * Get url connection status/*ww  w.  ja  v a 2s  .co m*/
 *
 * @return
 */
private String getStatus(Job job) {
    String responseCode;
    try {
        if (logger.isInfoEnabled()) {
            logger.info(" pinging " + job.getUrl());
        }

        HttpURLConnection connection = (HttpURLConnection) new URL(job.getUrl()).openConnection();
        connection.setRequestMethod("GET");
        responseCode = String.valueOf(connection.getResponseCode());
        return responseCode;

    } catch (ProtocolException pe) {
        responseCode = pe.getMessage();
    } catch (IOException io) {
        responseCode = io.getMessage();
    } catch (RuntimeException re) {
        responseCode = re.getMessage();
    }
    return responseCode;

}

From source file:org.cloudfoundry.caldecott.client.HttpTunnel.java

private void openTunnel() {
    String initMsg = "{\"host\":\"" + host + "\",\"port\":" + port + "}";
    if (logger.isDebugEnabled()) {
        logger.debug("Initializing tunnel: " + initMsg);
    }//  w ww. j a  v  a  2  s . c om
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("Auth-Token", auth);
    requestHeaders.set("Content-Length", initMsg.length() + "");
    HttpEntity<String> requestEntity = new HttpEntity<String>(initMsg, requestHeaders);
    String jsonResponse;
    try {
        jsonResponse = restOperations.postForObject(url + "/tunnels", requestEntity, String.class);
    } catch (RuntimeException e) {
        logger.error("Fatal error while opening tunnel: " + e.getMessage());
        close();
        throw e;
    }
    try {
        this.tunnelInfo = TunnelHelper.convertJsonToMap(jsonResponse);
    } catch (IOException ignore) {
        this.tunnelInfo = new HashMap<String, String>();
    }
}

From source file:com.legstar.codegen.CodeGenMakeTest.java

/**
 * Check controls on input make file tag &lt;cixstarget name=""&gt;.
 * @throws IOException if file cannot be read
 *///  ww w. j a  va  2s  .c o m
public void testCodeGenMakeNoTargetName() throws IOException {
    File tempMakeFile = File.createTempFile("test-temp", "xml");
    /* Create a temporary make file */
    BufferedWriter out;
    out = new BufferedWriter(new FileWriter(tempMakeFile));
    out.write("<target/>");
    out.close();

    CodeGenMake codeGenMake = new CodeGenMake();
    codeGenMake.setModelName("modelName");
    codeGenMake.setModel("model");
    codeGenMake.setCodeGenMakeFileName(tempMakeFile.getPath());
    try {
        codeGenMake.execute();
    } catch (RuntimeException e) {
        assertEquals("Missing name attribute for target element", e.getMessage());
    }
}