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.sun.faces.lifecycle.ProcessValidationsPhase.java

public void execute(FacesContext facesContext) throws FacesException {
    if (log.isDebugEnabled()) {
        log.debug("Entering ProcessValidationsPhase");
    }//from w  w w .ja  v a 2 s .c  o m
    UIComponent component = facesContext.getViewRoot();
    Util.doAssert(null != component);

    try {
        component.processValidators(facesContext);
    } catch (RuntimeException re) {
        String exceptionMessage = re.getMessage();
        if (null != exceptionMessage) {
            if (log.isErrorEnabled()) {
                log.error(exceptionMessage, re);
            }
        }
        throw new FacesException(exceptionMessage, re);
    }
    if (log.isDebugEnabled()) {
        log.debug("Exiting ProcessValidationsPhase");
    }
}

From source file:com.threewks.thundr.bigmetrics.admin.BigMetricsQueryController.java

public JsonView executeQuery(String query) {
    if (StringUtils.isBlank(query)) {
        return new JsonView("No query specified").withStatusCode(StatusCode.BadRequest);
    }/*from  www  .  java  2 s . c  o  m*/
    try {
        Logger.info("Starting query: '%s'", query);
        String reference = bigMetricsService.startQuery(query);
        return new JsonView(Expressive.map("jobId", reference)).withStatusCode(StatusCode.Accepted);
    } catch (RuntimeException e) {
        Logger.warn("Failed to run query %s: %s", query, e.getMessage());
        return new JsonView("Failed " + e.getMessage()).withStatusCode(StatusCode.InternalServerError);
    }
}

From source file:com.phonegap.plugins.databasepath.DatabasePath.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    try {// w  ww . ja v  a2 s .  c om
        if (action.equals("getDatabasePath")) {
            //String databasePath = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
            //String databasePath = this.cordova.getActivity().getDatabasePath("ClinidataPHR_DB").getAbsolutePath();
            String databasePath = "";
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                databasePath = "file:///data/data/" + webView.getContext().getPackageName()
                        + "/app_database/file__0/0000000000000001.db";
            } else {
                databasePath = "file:///data/data/" + webView.getContext().getPackageName()
                        + "/app_webview/databases/file__0/1";
            }
            callbackContext.success(databasePath);
            return true;
        }
    } catch (RuntimeException e) { // KLUDGE for Activity Not Found
        e.printStackTrace();
        callbackContext.error(e.getMessage());
    }
    return false;
}

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

@Test
public void shouldThrowExceptionWhenChecksumsDoNotMatch() throws IOException {
    when(checksums.md5For("src/file/path")).thenReturn("wrong_md5");
    fileHandler.useArtifactMd5Checksums(checksums);

    try {//  w  w  w. j  a v a2s.  c o m
        fileHandler.handle(new ByteArrayInputStream("Hello world".getBytes()));
        fileHandler.handleResult(200, goPublisher);
        fail("Should throw exception when checksums do not match.");
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), is("Artifact download failed for [src/file/path]"));
        assertThat(goPublisher.getMessage(), containsString(
                "[ERROR] Verification of the integrity of the artifact [src/file/path] failed. The artifact file on the server may have changed since its original upload."));
    }
}

From source file:org.opentestsystem.ap.ivs.rest.ExceptionAdvice.java

@ExceptionHandler(UnauthorizedException.class)
public ResponseEntity<List<ErrorMessage>> handleUnauthorizedError(final RuntimeException ex) {
    log.error("User Unauthorized", ex);
    return generateResponse(ex.getMessage(), UNAUTHORIZED);
}

From source file:com.dianping.cache.servlet.RestCacheManagementServlet.java

/**
 * Get building message parameters, and then send this message to JMS
 * server.//w  ww  . j av  a  2  s  .  c  o  m
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    PrintWriter out = resp.getWriter();
    try {
        String uri = req.getRequestURI();
        if (StringUtils.isBlank(uri)) {
            out.println("Uri can not be null or empty.");
        }
        String action = uri.substring(uri.lastIndexOf("/") + 1);
        if (action.indexOf("?") != -1) {
            action = action.substring(0, action.indexOf("?"));
        }
        logger.info("uri:" + uri + ", action:" + action);
        if (!REQ_CLEAR_BY_CATEGORY.equalsIgnoreCase(action) && !REQ_CLEAR_BY_KEY.equalsIgnoreCase(action)
                && !REQ_INC_CATEGORY_VERSION.equalsIgnoreCase(action)
                && !REQ_PUSH_CATEGORY_CONFIG.equalsIgnoreCase(action)) {
            out.println("Invalid uri:" + uri
                    + "(Use clearCacheByCategory, clearCacheByKey, incCacheCategoryVersion or pushCacheCategoryConfig)");
        }

        ContextUtils.putLocalContext("CLIENT_IP", IPUtils.getUserIP(req));
        if (REQ_CLEAR_BY_CATEGORY.equalsIgnoreCase(action)) {
            cacheManageService.clearByCategory(req.getParameter(PARAM_CATEGORY), req.getParameter(PARAM_IPS));
        } else if (REQ_CLEAR_BY_KEY.equalsIgnoreCase(action)) {
            cacheManageService.clearByKey(req.getParameter(PARAM_CACHETYPE), req.getParameter(PARAM_KEY));
        } else if (REQ_INC_CATEGORY_VERSION.equalsIgnoreCase(action)) {
            cacheManageService.incVersion(req.getParameter(PARAM_CATEGORY));
        } else {
            cacheManageService.pushCategoryConfig(req.getParameter(PARAM_CATEGORY),
                    req.getParameter(PARAM_IPS));
        }

        out.println("OK");
    } catch (RuntimeException e) {
        out.println("ERROR: " + e.getMessage());
    } finally {
        out.close();
    }
}

From source file:br.com.mandado.bean.AutenticacaoBean.java

/**
 * @return/*from  w w  w  .  java  2 s.  c om*/
 */
public String autenticar() {
    try {
        UsuarioDAO usuarioDAO = new UsuarioDAO();
        usuarioLogado = usuarioDAO.autenticar(usuarioLogado.getCpf(),
                DigestUtils.md5Hex(usuarioLogado.getSenha()));

        if (usuarioLogado == null) {
            FacesUtil.adicionarMsgErro("CPF e/ou senha invlidos");
            return null;
        } else {
            FacesUtil.adicionarMsgInfo("Usurio autenticado com sucesso!");
            return "/pages/principal.xhtml?faces-redirect=true";
        }
    } catch (RuntimeException ex) {
        FacesUtil.adicionarMsgErro("Erro ao tentar autenticar no sistema: " + ex.getMessage());
        return null;
    }
}

From source file:com.sun.faces.lifecycle.ApplyRequestValuesPhase.java

public void execute(FacesContext facesContext) throws FacesException {

    if (log.isDebugEnabled()) {
        log.debug("Entering ApplyRequestValuesPhase");
    }// w ww .  j  a v a  2  s.c  o m

    UIComponent component = facesContext.getViewRoot();
    Util.doAssert(null != component);

    try {
        component.processDecodes(facesContext);
    } catch (RuntimeException re) {
        String exceptionMessage = re.getMessage();
        if (null != exceptionMessage) {
            if (log.isErrorEnabled()) {
                log.error(exceptionMessage, re);
            }
        }
        throw new FacesException(exceptionMessage, re);
    }
    if (log.isDebugEnabled()) {
        log.debug("Exiting ApplyRequestValuesPhase");
    }
}

From source file:cs.rsa.ts14dist.client.StandardClientRequestHandler.java

@Override
public String getContents(String user) throws IOException {
    // Build the json request object 
    JSONObject requestJson = CommandLanguage.createRequestObject(user, Constants.GETCONTENTS_REQUEST,
            "notused");
    String report;//  ww w  .  jav a2s.  c  o  m

    try {
        // send the request over the connector and retrieve the reply object 
        JSONObject replyJson = requestAndAwaitReply(requestJson, Priority.LOW);
        // Extract the return value 
        report = (String) replyJson.get(Constants.RETURNVALUE_KEY);
    } catch (RuntimeException e) {
        report = e.getMessage();
    }
    return report;
}

From source file:cs.rsa.ts14dist.client.StandardClientRequestHandler.java

@Override
public String getReport(String user, String overviewType) throws IOException {
    // Build the json request object 
    JSONObject requestJson = CommandLanguage.createRequestObject(user, Constants.GETREPORT_REQUEST,
            overviewType);//from w  ww. ja  va 2  s .c  o  m
    String report;
    try {
        // send the request over the connector and retrieve the reply object 
        JSONObject replyJson = requestAndAwaitReply(requestJson, Priority.LOW);
        // Extract the return value 
        report = (String) replyJson.get(Constants.RETURNVALUE_KEY);
    } catch (RuntimeException e) {
        report = e.getMessage();
    }

    return report;
}