Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheckTest.java

@Test
public void testIllegalStateException() throws Exception {
    UncommentedMainCheck check = new UncommentedMainCheck();
    DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.CTOR_DEF, "ctor"));
    try {/*  w  ww  .  j  a v  a 2s  . com*/
        check.visitToken(ast);
        Assert.fail();
    } catch (IllegalStateException ex) {
        assertEquals(ast.toString(), ex.getMessage());
    }

}

From source file:ome.tools.FileSystem.java

/**
 * This method will return the free space in kilobytes TODO - resolve the
 * slash mount//from   ww  w  . j  av a 2  s.  c  o  m
 * 
 * @return long of free space
 */
public long free(String mountRoot) throws RuntimeException {
    long result = 0L;

    try {
        result = FileSystemUtils.freeSpaceKb(mountRoot);
    } catch (IOException ioex) {
        throw new RuntimeException(ioex.getMessage());
    } catch (IllegalArgumentException illex) {
        throw new RuntimeException(illex.getMessage());
    } catch (IllegalStateException stex) {
        throw new RuntimeException(stex.getMessage());
    }

    return result;
}

From source file:net.pms.io.OutputTextLogger.java

public void run() {
    LineIterator it = null;/*from www  . j a  v  a  2s  . c  o  m*/

    try {
        it = IOUtils.lineIterator(inputStream, "UTF-8");

        while (it.hasNext()) {
            String line = it.nextLine();
            logger.debug(line);
        }
    } catch (IOException ioe) {
        logger.debug("Error consuming input stream: {}", ioe.getMessage());
    } catch (IllegalStateException ise) {
        logger.debug("Error reading from closed input stream: {}", ise.getMessage());
    } finally {
        LineIterator.closeQuietly(it); // clean up all associated resources
    }
}

From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.AbstractNewFileWizard.java

@Override
protected void onWizardFinished() {
    try {//from   w  w w .ja va 2  s. c o m
        File file = getFile();
        file.setProject(EntityUtils.lightweightClone(file.getProject()));
        file.setType(getFileType());
        file.setData(createData());
        manager.create(file);
    } catch (IllegalStateException e) {
        // hack for NewTestbenchWizard to cancel wizard
        if (!e.getMessage().equals("Dialog canceled")) {
            throw e;
        }
    }
}

From source file:com.puppetlabs.geppetto.injectable.eclipse.impl.ProxiedRoutePlanner.java

@Override
public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context)
        throws HttpException {
    if (request == null) {
        throw new IllegalStateException("Request must not be null.");
    }/*w  w w  .  ja  v a  2 s. c  om*/

    // If we have a forced route, we can do without a target.
    HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams());
    if (route != null)
        return route;

    // If we get here, there is no forced route.
    // So we need a target to compute a route.

    if (target == null) {
        throw new IllegalStateException("Target host must not be null.");
    }

    final InetAddress local = ConnRouteParams.getLocalAddress(request.getParams());
    final HttpHost proxy = ConnRouteParams.getDefaultProxy(request.getParams());

    final Scheme schm;
    try {
        schm = schemeRegistry.getScheme(target.getSchemeName());
    } catch (IllegalStateException ex) {
        throw new HttpException(ex.getMessage());
    }
    // as it is typically used for TLS/SSL, we assume that
    // a layered scheme implies a secure connection
    final boolean secure = schm.isLayered();

    if (proxy != null)
        return new HttpRoute(target, local, proxy, secure);

    IProxyData[] select = Activator.getInstance().getProxyService().select(URI.create(target.toURI()));
    for (IProxyData proxyData : select)
        if (proxyData.getType().equals(IProxyData.HTTP_PROXY_TYPE)) {
            HttpHost proxyHost = new HttpHost(proxyData.getHost(), proxyData.getPort());
            return new HttpRoute(target, null, proxyHost, secure);
        }

    return new HttpRoute(target, local, secure);
}

From source file:hello.job.ProcessGreetingsJob.java

@Override
protected IStatus run(final IProgressMonitor monitor) {
    try {/*  www. j a va2  s  .c o  m*/
        LOG.info("Job {} started.", getJobContext().getJobId());
        getGreetingService().processGreetings();
        LOG.info("Job {} finished.", getJobContext().getJobId());
        return Status.OK_STATUS;
    } catch (final IllegalStateException e) {
        LOG.error("Unable to process greetings. {}", e.getMessage(), e);
        return new Status(IStatus.CANCEL, "hello.cloud", "Unable to processing greetings. " + e.getMessage(),
                e);
    } catch (final Exception e) {
        LOG.error("Error processing greetings: {}", ExceptionUtils.getRootCauseMessage(e), e);
        return new Status(IStatus.ERROR, "hello.cloud", "Error processing greetings. " + e.getMessage(), e);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheckTest.java

@Test
public void testCallVisitToken() throws Exception {
    TrailingCommentCheck check = new TrailingCommentCheck();
    try {/*from w w w . j av a 2s.  com*/
        check.visitToken(new DetailAST());
        Assert.fail();
    } catch (IllegalStateException ex) {
        assertEquals("visitToken() shouldn't be called.", ex.getMessage());
    }
}

From source file:org.elasticsearch.client.sniff.SniffOnFailureListenerTests.java

public void testSetSniffer() throws Exception {
    SniffOnFailureListener listener = new SniffOnFailureListener();

    try {//from  w ww .j ava2s  . c  om
        listener.onFailure(null);
        fail("should have failed");
    } catch (IllegalStateException e) {
        assertEquals("sniffer was not set, unable to sniff on failure", e.getMessage());
    }

    try {
        listener.setSniffer(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("sniffer must not be null", e.getMessage());
    }

    try (RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build()) {
        try (Sniffer sniffer = Sniffer.builder(restClient).setHostsSniffer(new MockHostsSniffer()).build()) {
            listener.setSniffer(sniffer);
            try {
                listener.setSniffer(sniffer);
                fail("should have failed");
            } catch (IllegalStateException e) {
                assertEquals("sniffer can only be set once", e.getMessage());
            }
            listener.onFailure(new HttpHost("localhost", 9200));
        }
    }
}

From source file:io.github.seleniumquery.browser.driver.builders.PhantomJSDriverBuilder.java

private void throwCustomExceptionIfExecutableWasNotFound(IllegalStateException e) {
    if (e.getMessage().contains("path to the driver executable must be set")) {
        throw new SeleniumQueryException(format(
                "The PhantomJS executable (%s/%s) was not found in the classpath, in the \"%s\" system property or in the system's PATH variable. %s",
                phantomjsExecutableWindows, phantomjsExecutableLinux, PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
                EXCEPTION_MESSAGE), e);//from w  w  w .  ja  v  a2 s.c  o m
    }
}

From source file:org.apache.hadoop.hbase.errorhandling.TestTimeoutExceptionInjector.java

/**
 * Demonstrate TimeoutExceptionInjector semantics -- completion means no more exceptions passed to
 * error listener.//from w ww .j  a v  a  2  s  .  com
 */
@Test(timeout = 60000)
public void testStartAfterComplete() throws InterruptedException {
    final long time = 10;
    ForeignExceptionListener listener = Mockito.mock(ForeignExceptionListener.class);
    TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time);
    timer.complete();
    try {
        timer.start();
        fail("Timer should fail to start after complete.");
    } catch (IllegalStateException e) {
        LOG.debug("Correctly failed timer: " + e.getMessage());
    }
    Thread.sleep(time + 1);
    Mockito.verifyZeroInteractions(listener);
}