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:jenkins.plugins.coverity.CoverityTool.CovAnalyzeCommandTest.java

@Test
public void addMisraConfigurationTest_WithEmptyMisraConfigFilePath() throws IOException, InterruptedException {
    InvocationAssistance invocationAssistance = new InvocationAssistanceBuilder().withMisraConfigFile("")
            .build();/*from   www .  j  ava  2s  .  c  om*/
    CoverityPublisher publisher = new CoverityPublisherBuilder().withInvocationAssistance(invocationAssistance)
            .build();

    Command covAnalyzeCommand = new CovAnalyzeCommand(build, launcher, listener, publisher, StringUtils.EMPTY,
            envVars);
    try {
        covAnalyzeCommand.runCommand();
        fail("RuntimeException should have been thrown");
    } catch (RuntimeException e) {
        assertEquals("Misra configuration file is required to run Misra analysis.", e.getMessage());
    }
}

From source file:com.github.carlomicieli.rest.resources.BrandsResource.java

@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response post(BrandRepresentation brandRep) {
    log.info("POST /brands");

    final Brand brand = brandRep.getInner();

    try {/*w  ww.  ja v a  2s  . c  om*/
        long id = brandService.create(brand);

        // the response contains the ETag for the resource just created.
        return Response.created(URI.create(Long.toString(id))).tag(brandRep.tag()).build();
    } catch (RuntimeException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.github.carlomicieli.rest.resources.BrandsResource.java

/**
 * Update the brand resource./*from ww w .ja v a 2s  .co m*/
 * <p>
 * <code>PUT /brands</code>
 * </p>
 * 
 * @param brandRep the brand representation.
 * @return HTTP response.
 */
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response put(BrandRepresentation brandRep) {
    log.info("PUT /brands");

    final Brand brand = brandRep.getInner();

    try {
        brandService.save(brand);

        return Response.noContent().build();
    } catch (RuntimeException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.github.carlomicieli.rest.resources.RailwaysResource.java

@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response post(RailwayRepresentation railwayRep) {
    log.info("POST /railways");

    final Railway railway = railwayRep.getInner();

    try {/*from  w w w. j  a v a2 s .c om*/
        long id = railwayService.create(railway);

        // the response contains the ETag for the resource just created.
        return Response.created(URI.create(Long.toString(id))).tag(railwayRep.tag()).build();
    } catch (RuntimeException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.github.carlomicieli.rest.resources.RailwaysResource.java

/**
 * Update the brand resource.//from   ww w. ja  v  a 2 s  .c o m
 * <p>
 * <code>PUT /railways</code>
 * </p>
 * 
 * @param brandRep the brand representation.
 * @return HTTP response.
 */
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response put(RailwayRepresentation railwayRep) {
    log.info("PUT /railways");

    final Railway railway = railwayRep.getInner();

    try {
        railwayService.save(railway);

        return Response.noContent().build();
    } catch (RuntimeException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:jenkins.plugins.coverity.CoverityTool.CovAnalyzeCommandTest.java

@Test
public void addTestAdvisorConfigurationTest_WithEmptyTaPolicyFilePath()
        throws IOException, InterruptedException {
    TaOptionBlock taOptionBlock = new TaOptionBlockBuilder().build();
    CoverityPublisher publisher = new CoverityPublisherBuilder().withTaOptionBlock(taOptionBlock).build();

    Command covAnalyzeCommand = new CovAnalyzeCommand(build, launcher, listener, publisher, StringUtils.EMPTY,
            envVars);//  w  w  w .  j  a v a  2 s  .  c  o  m
    try {
        covAnalyzeCommand.runCommand();
        fail("RuntimeException should have been thrown");
    } catch (RuntimeException e) {
        assertEquals("Test Advisor Policy File is required to run the Test Advisor.", e.getMessage());
    }
}

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

@Override
public void update(PrintedBook printedBook) {
    if (printedBook == null) {
        throw new IllegalArgumentException("printed book in update is null");
    }/*from  w  ww. j a va 2  s . co m*/

    try {
        PrintedBook pb = find(printedBook);

        if (pb == null) {
            throw new IllegalArgumentException("printed book after find is null");
        }

        pb.setBook(printedBook.getBook());
        pb.setCondition(printedBook.getCondition());
        pb.setState(printedBook.getState());
        em.persist(pb);
    } catch (RuntimeException E) {
        throw new DAException(E.getMessage());
    }
}

From source file:net.solarnetwork.node.setup.web.InstructorController.java

@RequestMapping(value = "/manage", method = RequestMethod.GET)
public String manage(@RequestParam("id") String controlId, ModelMap model) {
    NodeControlProvider provider = null;
    for (NodeControlProvider p : providers) {
        for (String s : p.getAvailableControlIds()) {
            if (s.equals(controlId)) {
                provider = p;/*from   www . j av a 2s  . c  o m*/
                break;
            }
        }
        if (provider != null) {
            break;
        }
    }
    if (provider != null) {
        model.put(KEY_CONTROL_ID, controlId);
        NodeControlInfo info = null;
        try {
            info = provider.getCurrentControlInfo(controlId);
        } catch (RuntimeException e) {
            log.warn("Error getting control {} info: {}", controlId, e.getMessage());
        }
        if (info != null) {
            model.put(KEY_CONTROL_INFO, info);
        }
    }
    return "control/manage";
}

From source file:com.lzs.core.support.ShiroDbRealm.java

/**
 * ?,.//w  w w.j a  v  a 2 s. c o m
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
        throws AuthenticationException {
    try {
        UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
        String userName = token.getUsername();
        String plainPassword = String.valueOf(token.getPassword());
        if (userName != null && !"".equals(userName)) {
            User user = userService.findUniqueBy("username", token.getUsername());
            if (user == null || user.getDeleted() == 1) {
                throw new NoResultException("??");
            }
            PasswordService passwordService = new DefaultPasswordService();
            if (passwordService.passwordsMatch(plainPassword, user.getPassword())) {
                return new SimpleAuthenticationInfo(new ShiroUser(user.getId(), user.getUsername()),
                        plainPassword, getName());
            }
        }
    } catch (NoResultException e) {
        RuntimeException re = new RuntimeException("??", e);
        logger.error(re.getMessage(), re);
        throw re;
    } catch (NonUniqueResultException e) {
        RuntimeException re = new RuntimeException("????", e);
        logger.error(re.getMessage(), re);
        throw re;
    } catch (Exception e) {
        logger.error("", e);
    }

    throw new RuntimeException("??");
}

From source file:com.android.email.service.ImapTempFileLiteral.java

@Override
public void destroy() {
    try {/*from   www .  j  av  a 2  s  .  c om*/
        if (!isDestroyed() && mFile.exists()) {
            mFile.delete();
        }
    } catch (RuntimeException re) {
        // Just log and ignore.
        LogUtils.w(Logging.LOG_TAG, "Failed to remove temp file: " + re.getMessage());
    }
    super.destroy();
}