Example usage for com.fasterxml.jackson.core JsonProcessingException getStackTrace

List of usage examples for com.fasterxml.jackson.core JsonProcessingException getStackTrace

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonProcessingException getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:org.metis.sql.SqlJob.java

/**
 * Polls the DB and notifies clients of a change in the DB or a fatal error.
 * //  w w w .ja  v  a2  s.co  m
 * @return
 * @throws Exception
 */
private String pollDB() throws Exception {

    SqlResult sqlResult = null;

    try {

        // execute the sql statement. if a sqlResult was not returned,
        // then an error occurred and this job must be considered
        // defunct.
        if ((sqlResult = sqlStmnt.execute(getlParams())) == null) {
            // execute will have logged the necessary debug/error info.
            // notify all subscribed clients, that an error has occurred
            // and that this job is being stopped
            LOG.error(getThreadName() + ":ERROR, execute did not return a sqlResult object");
            sendInternalServerError("");
            throw new Exception("execute returns null sqlResult");
        }

        // sqlResult was returned, but it may not contain a result set
        List<Map<String, Object>> listMap = sqlResult.getResultSet();
        String jsonOutput = null;
        if (listMap == null || listMap.isEmpty()) {
            LOG.trace(getThreadName() + ":sqlResult did not contain a result set");
        } else {
            // convert the result set to a json object
            jsonOutput = Utils.generateJson(listMap);
            if (LOG.isTraceEnabled()) {
                if (jsonOutput.length() > 100) {
                    LOG.trace(getThreadName() + ": first 100 bytes of acquired result set = "
                            + jsonOutput.substring(0, 100));
                } else {
                    LOG.trace(getThreadName() + ": acquired this result set - " + jsonOutput);
                }
            }
        }

        // get the digital signature of the json object (if any) that
        // represents the result set
        String dSign = (jsonOutput != null) ? getHashOf(jsonOutput) : WS_DFLT_SIGNATURE;
        LOG.trace(getThreadName() + ": acquired digital signature = " + dSign);
        LOG.trace(getThreadName() + ": current  digital signature = " + getDigitalSignature());

        // determine if a change has occurred
        if (getDigitalSignature() == null) {
            // first time, so just update the current digital signature
            setDigitalSignature(dSign);
        } else if (!dSign.equals(getDigitalSignature())) {
            // update the current digital signature
            setDigitalSignature(dSign);
            // ... and send the notification
            LOG.debug(getThreadName() + ": sending notification");
            sendChangeNotification(dSign);
            return getDigitalSignature();
        }

    } catch (JsonProcessingException exc) {
        LOG.error(getThreadName() + ":ERROR, caught this " + "JsonProcessingException while trying to gen json "
                + "message: " + exc.toString());
        LOG.error(getThreadName() + ": exception stack trace follows:");
        dumpStackTrace(exc.getStackTrace());
        if (exc.getCause() != null) {
            LOG.error(getThreadName() + ": Caused by " + exc.getCause().toString());
            LOG.error(getThreadName() + ": causing exception stack trace follows:");
            dumpStackTrace(exc.getCause().getStackTrace());
        }
        sendInternalServerError("");
        throw exc;

    } catch (Exception exc) {
        LOG.error(getThreadName() + ":ERROR, caught this " + "Exception while trying to gen json " + "message: "
                + exc.toString());
        LOG.error(getThreadName() + ": exception stack trace follows:");
        dumpStackTrace(exc.getStackTrace());
        if (exc.getCause() != null) {
            LOG.error(getThreadName() + ": Caused by " + exc.getCause().toString());
            LOG.error(getThreadName() + ": causing exception stack trace follows:");
            dumpStackTrace(exc.getCause().getStackTrace());
        }
        sendInternalServerError("");
        throw exc;
    } finally {
        if (sqlResult != null) {
            SqlResult.enqueue(sqlResult);
        }
    }

    return null;
}

From source file:org.opencb.opencga.server.rest.OpenCGAWSServer.java

protected Response createJsonResponse(QueryResponse queryResponse) {
    try {//from  ww  w .ja  v a  2 s  .  com
        return buildResponse(Response.ok(jsonObjectWriter.writeValueAsString(queryResponse),
                MediaType.APPLICATION_JSON_TYPE));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        logger.error("Error parsing queryResponse object");
        return createErrorResponse("",
                "Error parsing QueryResponse object:\n" + Arrays.toString(e.getStackTrace()));
    }
}

From source file:org.opencb.opencga.storage.server.rest.GenericRestWebService.java

protected Response createJsonResponse(Object object) {
    try {/*from www.j  av a 2s .c  o  m*/
        return buildResponse(
                Response.ok(jsonObjectWriter.writeValueAsString(object), MediaType.APPLICATION_JSON_TYPE));
    } catch (JsonProcessingException e) {
        return createErrorResponse(
                "Error parsing QueryResponse object:\n" + Arrays.toString(e.getStackTrace()));
    }
}