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:br.com.livraria.bean.FuncionarioBean.java

public void editar() {
    try {//ww  w  . j a va2  s . com
        FuncionarioDAO funcionarioDAO = new FuncionarioDAO();
        funcionarioCadastro.setSenha(DigestUtils.md5Hex(funcionarioCadastro.getSenha()));
        funcionarioDAO.editar(funcionarioCadastro);

        FacesUtil.adicionarMsgInfo("Funcionrio editado com sucesso");
    } catch (RuntimeException ex) {
        FacesUtil.adicionarMsgError("Erro ao tentar editar od dados do funcionrio:" + ex.getMessage());
    }

}

From source file:com.expedia.client.WunderGroundClient.java

@Override
public ResponseEntity<Response> getXMLResponse(Object request) {
    ResponseEntity<Response> responseEntity = null;
    Weather weather = null;//  w  w w . j  a  va  2  s  .  c  om

    if (request instanceof Weather) {
        weather = (Weather) request;
        List<MediaType> mediaTypes = new ArrayList<MediaType>();
        mediaTypes.add(MediaType.APPLICATION_XML);
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(mediaTypes);
        HttpEntity<Weather> httpEntity = new HttpEntity<Weather>(null, headers);
        try {
            System.out.println("Hitting weather service!");
            responseEntity = restTemplate.exchange(weatherServiceXmlUrl, HttpMethod.GET, httpEntity,
                    Response.class, weatherApiKey, weather.getZipCode());
        } catch (RuntimeException e) {
            e.printStackTrace();
            weather.setErrorDesc("Get failed" + e.getMessage());
        }
    }
    return responseEntity;
}

From source file:com.expedia.client.WunderGroundClient.java

@Override
public ResponseEntity<ResponseWrapper> getJSONResponse(Object request) {
    ResponseEntity<ResponseWrapper> responseEntity = null;
    Weather weather = null;/*  w  w  w.j a v  a  2 s .c om*/

    if (request instanceof Weather) {
        weather = (Weather) request;
        List<MediaType> mediaTypes = new ArrayList<MediaType>();
        mediaTypes.add(MediaType.APPLICATION_JSON);
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(mediaTypes);
        HttpEntity<Weather> httpEntity = new HttpEntity<Weather>(null, headers);
        try {
            System.out.println("Hitting weather service for JSON response!");
            responseEntity = restTemplate.exchange(weatherServiceJsonUrl, HttpMethod.GET, httpEntity,
                    ResponseWrapper.class, weatherApiKey, weather.getZipCode());
        } catch (RuntimeException e) {
            e.printStackTrace();
            weather.setErrorDesc("Get failed" + e.getMessage());
        }
    }
    return responseEntity;
}

From source file:cz.fi.muni.pa165.dao.PrintedBookDAOImpl.java

@Override
public List<PrintedBook> findPrintedBooks(Book book) {
    if (book == null) {
        throw new IllegalArgumentException("Book null");
    }/*from  w w  w  . j ava  2 s  .  c  o m*/

    try {
        final Query query = em.createQuery("SELECT m FROM PrintedBook as m WHERE m.book.idBook = :i");
        query.setParameter("i", book.getIdBook());
        return query.getResultList();
    } catch (RuntimeException E) {
        throw new DAException(E.getMessage());
    }
}

From source file:cz.fi.muni.pa165.dao.PrintedBookDAOImpl.java

@Override
public PrintedBook find(PrintedBook t) {
    if (t == null) {
        throw new IllegalArgumentException("Printed Book null");
    }// w  w  w  .  j  a va2s . com

    try {
        final Query query = em.createQuery("SELECT m FROM PrintedBook as m WHERE m.idPrintedBook = :i");
        query.setParameter("i", t.getIdPrintedBook());
        return (PrintedBook) query.getSingleResult();
    } catch (RuntimeException E) {
        throw new DAException(E.getMessage());
    }
}

From source file:com.rhc.dynamic.pipeline.ReleasePipelineVisitorWithConfigFileTest.java

@Test
public void shouldThrowExceptionForUnsupportedBuildTool() throws IOException {
    // given/*from  w ww  .  j  a  va  2 s . c  om*/
    DynamicPipelineFactory factory = new DynamicPipelineFactory(mockScript).withReleaseType()
            .withConfigurationFile(TestUtils.UNSUPPORTED_BUILD_TOOL_FILE)
            .withApplicationName(TestUtils.APPLICATION_NAME);

    // when
    try {
        factory.generatePipelineScript();
        Assert.fail("did not throw error");
    } catch (RuntimeException e) {
        // then
        if (e.getMessage() != null && e.getMessage().contains("gradle-3 is currently unsupported")) {
            // do nothing, this is desired behavior
        } else {
            Assert.fail("this is the wrong exception " + e.getMessage());
        }
    }
}

From source file:com.rhc.dynamic.pipeline.ReleasePipelineVisitorWithConfigFileTest.java

@Test
public void shouldThrowExceptionBecauseFirstProjectIsNotABuildEnv() throws IOException {
    // given/*from   w  ww .  ja  v  a  2s . c om*/
    DynamicPipelineFactory factory = new DynamicPipelineFactory(mockScript).withReleaseType()
            .withConfigurationFile(TestUtils.PROMOTION_ENV_FIRST_FILE)
            .withApplicationName(TestUtils.APPLICATION_NAME);

    // when
    try {
        factory.generatePipelineScript();
        Assert.fail("did not throw error");
    } catch (RuntimeException e) {
        // then
        if (e.getMessage() != null && e.getMessage().equals(VisitPlanner.BUILD_ENV_ERR)) {
            // do nothing, this is desired behavior
        } else {
            Assert.fail("this is the wrong exception " + e.getMessage());
        }
    }
}

From source file:com.cloudbees.demo.beesshop.service.AmazonS3FileStorageService.java

@Override
public void afterPropertiesSet() throws Exception {
    this.amazonS3 = new AmazonS3Client(awsCredentials);

    try {//  w  w w. j  a  v  a2 s  .  co m
        checkConfiguration();
    } catch (RuntimeException e) {
        logger.warn("Amazon S3 configuration problem: " + e.getMessage(), e);
    }
}

From source file:cz.fi.muni.pa165.dao.PrintedBookDAOImpl.java

@Override
public List<PrintedBook> findAllPrintedBooksByLoan(Loan loan) {
    if (loan == null) {
        throw new IllegalArgumentException("Book null");
    }// w  w w.  j a v a 2  s.co  m

    try {
        final TypedQuery<PrintedBook> query = em
                .createQuery("SELECT m FROM PrintedBook as m WHERE m.loan.idLoan = :lid", PrintedBook.class);
        query.setParameter("lid", loan.getIdLoan());
        return query.getResultList();
    } catch (RuntimeException E) {
        throw new DAException(E.getMessage());
    }
}

From source file:com.thoughtworks.go.domain.DirHandlerTest.java

@Test
public void shouldThrowExceptionWhenChecksumsDoNotMatch() throws IOException {
    when(checksums.md5For("fetch_dest/first")).thenReturn("foo");
    dirHandler.useArtifactMd5Checksums(checksums);
    zip = createZip("under_dir");

    try {/*www.ja v a 2 s  .  co  m*/
        dirHandler.handle(new FileInputStream(zip));
        dirHandler.handleResult(200, goPublisher);
        fail("Should throw exception when check sums do not match.");
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), is("Artifact download failed for [fetch_dest/first]"));
        assertThat(goPublisher.getMessage(), containsString(
                "[ERROR] Verification of the integrity of the artifact [fetch_dest/first] failed. The artifact file on the server may have changed since its original upload."));
    }
}