Example usage for java.lang Error getMessage

List of usage examples for java.lang Error getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.wso2.carbon.sequences.services.SequenceAdminService.java

/**
 * Add a sequence into the synapseConfiguration
 *
 * @param sequenceElement - Sequence object to be added as an OMElement
 * @throws SequenceEditorException if a sequence exists with the same name or if the
 *                                 element provided is not a Sequence element
 */// w  ww.j av a 2 s  .co m
public void addSequence(OMElement sequenceElement) throws SequenceEditorException {
    final Lock lock = SequenceAdminUtil.getLock();
    try {
        lock.lock();
        if (sequenceElement.getLocalName().equals(XMLConfigConstants.SEQUENCE_ELT.getLocalPart())) {
            String sequenceName = sequenceElement.getAttributeValue(new QName("name"));
            if ("".equals(sequenceName) || null == sequenceName) {
                handleException("sequence name is required.");
            }
            SynapseConfiguration config = SequenceAdminUtil.getSynapseConfiguration();
            if (log.isDebugEnabled()) {
                log.debug("Adding sequence : " + sequenceName + " to the configuration");
            }
            if (config.getLocalRegistry().get(sequenceName) != null) {
                handleException("The name '" + sequenceName
                        + "' is already used within the configuration - a sequence or local entry with this "
                        + "name already exists");
            } else {
                SynapseXMLConfigurationFactory.defineSequence(config, sequenceElement,
                        SequenceAdminUtil.getSynapseConfiguration().getProperties());
                if (log.isDebugEnabled()) {
                    log.debug("Added sequence : " + sequenceName + " to the configuration");
                }

                SequenceMediator seq = config.getDefinedSequences().get(sequenceName);
                seq.setFileName(ServiceBusUtils.generateFileName(sequenceName));
                seq.init(SequenceAdminUtil.getSynapseEnvironment());

                //noinspection ConstantConditions
                persistSequence(seq);
            }
        } else {
            handleException("Invalid sequence definition");
        }
    } catch (Exception fault) {
        handleException("Error adding sequence : " + fault.getMessage(), fault);
    } catch (Error error) {
        throw new SequenceEditorException(
                "Unexpected error occured while " + "adding the sequence : " + error.getMessage(), error);
    } finally {
        lock.unlock();
    }
}

From source file:org.nuxeo.ecm.core.storage.sql.DatabaseHelper.java

protected void setOwner() {
    if (owner != null) {
        Error e = new Error("Second call to setUp() without tearDown()", owner);
        log.fatal(e.getMessage(), e);
        throw e;//from w w w  .  ja v  a2  s  . c  om
    }
    owner = new Error("Database not released");
}

From source file:org.books.integration.AmazonCatalogBean.java

private void reportError(String methodName, List<Error> errorList) {

    LOGGER.log(Level.SEVERE, "{0}: response with errors", methodName);
    for (Error error : errorList) {
        LOGGER.log(Level.SEVERE, "{0}: - error({1}): {2}",
                new Object[] { methodName, error.getCode(), error.getMessage() });
    }//www.  j  a va 2 s  .co m
}

From source file:com.sulacosoft.bitcoindconnector4j.BitcoindApiHandler.java

private void checkBitcoindErrors(MorphDynaBean jsonError) throws BitcoindException {
    if (jsonError != null) {
        com.sulacosoft.bitcoindconnector4j.response.Error error = (com.sulacosoft.bitcoindconnector4j.response.Error) JSONObject
                .toBean(JSONObject.fromObject(jsonError),
                        com.sulacosoft.bitcoindconnector4j.response.Error.class);
        throw new BitcoindException(error.getMessage(), error.getCode());
    }//  w  w  w  .j a  va  2s. c  o  m
}

From source file:org.kuali.kra.award.AwardTemplateSyncScope.java

public String[] getSyncScopeParameters(String syncClass, String syncField) {
    String[] values = {};//from  w w w.  ja  v a 2s . c  om
    try {
        String settingValue = KcServiceLocator.getService(ParameterService.class).getParameterValueAsString(
                AwardDocument.class,
                String.format("scope.sync.%s.%s.%s", this.toString(), syncClass, syncField));
        values = settingValue == null ? new String[] {} : StringUtils.split(settingValue, ",");
    } catch (Error e) {
        LOG.error(String.format(
                "Error returned from parameter lookup scope.sync.%s.%s.%s failed, defaulting to empty list.  Error: %s",
                this.toString(), syncClass, syncField, e.getMessage()));
    }
    return values;
}

From source file:org.qedeq.kernel.bo.service.control.KernelQedeqBoStorage.java

/**
 * Validate module dependencies and throw Error if they are not correct.
 *//*from   ww  w .ja  va  2  s.c om*/
synchronized void validateDependencies() {
    final String method = "validateDependencies";
    String url = StringUtils.EMPTY;
    String text = StringUtils.EMPTY;
    boolean error = false;
    Trace.begin(CLASS, this, method);
    // for debugging: print dependency tree:
    //        for (final Iterator iterator = bos.entrySet().iterator(); iterator.hasNext(); ) {
    //            Map.Entry entry = (Map.Entry) iterator.next();
    //            final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) entry.getValue();
    //            prop.getStateManager().printDependencyTree();
    //        }
    for (final Iterator iterator = bos.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) entry.getValue();
        Trace.param(CLASS, this, method, "prop", prop);
        if (!prop.hasLoadedRequiredModules()) {
            continue;
        }

        // prop must be in dependent list for all required modules
        final KernelModuleReferenceList refs = prop.getKernelRequiredModules();
        for (int i = 0; i < refs.size(); i++) {
            final DefaultKernelQedeqBo ref = (DefaultKernelQedeqBo) refs.getKernelQedeqBo(i);
            final KernelModuleReferenceList dependents = ref.getDependentModules();
            if (!dependents.contains(prop)) {
                Trace.fatal(CLASS, this, method, ref.getUrl() + " missing dependent module: " + prop.getUrl(),
                        null);
                if (!error) {
                    url = ref.getUrl();
                    text = "missing dependent module " + prop.getUrl();
                }
                error = true;
            }
        }

        // for all dependent modules, prop must be in required list
        final KernelModuleReferenceList dependents = prop.getDependentModules();
        for (int i = 0; i < dependents.size(); i++) {
            final DefaultKernelQedeqBo dependent = (DefaultKernelQedeqBo) dependents.getKernelQedeqBo(i);
            final KernelModuleReferenceList refs2 = dependent.getKernelRequiredModules();
            if (!refs2.contains(prop)) {
                Trace.fatal(CLASS, this, method,
                        dependent.getUrl() + " missing required module: " + prop.getUrl(), null);
                if (!error) {
                    url = prop.getUrl();
                    text = "missing required module " + prop.getUrl();
                }
                error = true;
            }
        }
    }
    Trace.end(CLASS, this, method);

    // if the dependencies are not ok we throw an error!
    if (error) {
        Error e = new Error("QEDEQ dependencies and status are flawed! "
                + "This is a major error! We do a kernel shutdown!");
        Trace.fatal(CLASS, this, method, "Shutdown because of major validation error", e);
        QedeqLog.getInstance().logFailureReply(e.getMessage(), url, text);
        KernelContext.getInstance().shutdown();
        throw e;
    }
}

From source file:com.zuora.api.util.ZuoraUtility.java

/**
 * Creates the print format of the subscribe result value.
 * /*from w w w  .j  ava  2s.co  m*/
 * @param resultArray
 *          the result array
 * @return the string
 */
public String createMessage(SubscribeResult[] resultArray) {
    StringBuilder resultString = new StringBuilder("SusbscribeResult :\n");
    if (resultArray != null) {
        SubscribeResult result = resultArray[0];
        if (result.getSuccess()) {
            resultString.append("\nSubscribe Result: \n").append("\n\tAccount Id: ")
                    .append(result.getAccountId()).append("\n\tAccount Number: ")
                    .append(result.getAccountNumber()).append("\n\tSubscription Id: ")
                    .append(result.getSubscriptionId()).append("\n\tSubscription Number: ")
                    .append(result.getSubscriptionNumber()).append("\n\tInvoice Number: ")
                    .append(result.getInvoiceNumber()).append("\n\tPayment Transaction: ")
                    .append(result.getPaymentTransactionNumber());
        } else {
            resultString.append("\nSubscribe Failure Result: \n");
            Error[] errors = result.getErrors();
            if (errors != null) {
                for (Error error : errors) {
                    resultString.append("\n\tError Code: ").append(error.getCode().toString())
                            .append("\n\tError Message: ").append(error.getMessage());
                }
            }
        }
    }
    return resultString.toString();
}

From source file:io.apiman.test.common.util.TestPlanRunner.java

/**
 * Runs a single REST test.//from  ww w  .  j a  v a 2 s. c  om
 *
 * @param restTest
 */
private void runTest(RestTest restTest) throws Error {
    try {
        String requestPath = TestUtil.doPropertyReplacement(restTest.getRequestPath());
        URI uri = getUri(requestPath);
        HttpRequestBase request = null;
        if (restTest.getRequestMethod().equalsIgnoreCase("GET")) { //$NON-NLS-1$
            request = new HttpGet();
        } else if (restTest.getRequestMethod().equalsIgnoreCase("POST")) { //$NON-NLS-1$
            request = new HttpPost();
            HttpEntity entity = new StringEntity(restTest.getRequestPayload());
            ((HttpPost) request).setEntity(entity);
        } else if (restTest.getRequestMethod().equalsIgnoreCase("PUT")) { //$NON-NLS-1$
            request = new HttpPut();
            HttpEntity entity = new StringEntity(restTest.getRequestPayload());
            ((HttpPut) request).setEntity(entity);
        } else if (restTest.getRequestMethod().equalsIgnoreCase("DELETE")) { //$NON-NLS-1$
            request = new HttpDelete();
        }
        if (request == null) {
            Assert.fail("Unsupported method in REST Test: " + restTest.getRequestMethod()); //$NON-NLS-1$
        }
        request.setURI(uri);

        Map<String, String> requestHeaders = restTest.getRequestHeaders();
        for (Entry<String, String> entry : requestHeaders.entrySet()) {
            request.setHeader(entry.getKey(), entry.getValue());
        }

        // Set up basic auth
        String authorization = createBasicAuthorization(restTest.getUsername(), restTest.getPassword());
        if (authorization != null) {
            request.setHeader("Authorization", authorization); //$NON-NLS-1$
        }

        HttpResponse response = client.execute(request);
        assertResponse(restTest, response);
    } catch (Error e) {
        logPlain("[ERROR] " + e.getMessage()); //$NON-NLS-1$
        throw e;
    } catch (Exception e) {
        throw new Error(e);
    }

}

From source file:org.wso2.carbon.mediation.templates.services.EndpointTemplateEditorAdmin.java

private void addEndpointTemplate(OMElement templateElement) throws AxisFault {
    final Lock lock = getLock();
    try {/*from   w w  w.j ava2s. com*/
        lock.lock();
        if (templateElement.getLocalName().equals(XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) {
            String templateName = templateElement.getAttributeValue(new QName("name"));
            SynapseConfiguration config = getSynapseConfiguration();
            if (log.isDebugEnabled()) {
                log.debug("Adding template : " + templateName + " to the configuration");
            }
            if (config.getLocalRegistry().get(templateName) != null) {
                handleException("The name '" + templateName + "' is already used within the configuration");
            } else {
                SynapseXMLConfigurationFactory.defineEndpointTemplate(config, templateElement,
                        getSynapseConfiguration().getProperties());
                if (log.isDebugEnabled()) {
                    log.debug("Added template : " + templateName + " to the configuration");
                }

                Template templ = config.getEndpointTemplates().get(templateName);
                templ.setFileName(ServiceBusUtils.generateFileName(templateName));
                //                    templ.init(getSynapseEnvironment());

                //noinspection ConstantConditions
                persistTemplate(templ);
            }
        } else {
            handleException("Invalid template definition");
        }
    } catch (Exception fault) {
        handleException("Error adding template : " + fault.getMessage(), fault);
    } catch (Error error) {
        throw new AxisFault("Unexpected error occured while " + "adding the template : " + error.getMessage(),
                error);
    } finally {
        lock.unlock();
    }
}

From source file:gr.csri.poeticon.praxicon.CreateNeo4JDB.java

private void createGraph() {
    // Create graph
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(DB_PATH));
    Transaction tx = graphDb.beginTx();/*from  w w w  .  jav  a2  s .  c  o  m*/

    ConceptDao cDao = new ConceptDaoImpl();
    RelationDao rDao = new RelationDaoImpl();
    LanguageRepresentationDao lrDao = new LanguageRepresentationDaoImpl();
    MotoricRepresentationDao mrDao = new MotoricRepresentationDaoImpl();
    VisualRepresentationDao vrDao = new VisualRepresentationDaoImpl();
    RelationArgumentDao raDao = new RelationArgumentDaoImpl();
    RelationSetDao rsDao = new RelationSetDaoImpl();
    RelationTypeDao rtDao = new RelationTypeDaoImpl();

    System.out.println();
    System.out.println("---- MySQL ----");

    System.out.print("Downloading Concepts... ");
    List<Concept> concepts = cDao.getAllConcepts();
    System.out.println("" + concepts.size());

    System.out.print("Downloading LanguageRepresentations... ");
    List<LanguageRepresentation> langRepr = lrDao.findAll();
    System.out.println("" + langRepr.size());

    System.out.print("Downloading VisualRepresentations... ");
    List<VisualRepresentation> visRepr = vrDao.findAll();
    System.out.println("" + visRepr.size());

    System.out.print("Downloading MotoricRepresentations... ");
    List<MotoricRepresentation> motRepr = mrDao.findAll();
    System.out.println("" + motRepr.size());

    System.out.print("Downloading Relations... ");
    List<Relation> rels = rDao.findAll();
    System.out.println("" + rels.size());

    System.out.print("Downloading RelationSets... ");
    List<RelationSet> relsets = rsDao.findAll();
    System.out.println("" + relsets.size());

    System.out.println();
    System.out.println("---- Neo4J ----");
    try {
        System.out.print("Uploading LanguageRepresentations... ");
        for (LanguageRepresentation repr : langRepr) {
            conceptNode = graphDb.createNode();
            conceptNode.setProperty("id", repr.getId());
            conceptNode.setProperty("text", repr.getText());
            conceptNode.setProperty("lang", repr.getLanguage().toString());
            conceptNode.setProperty("pos", repr.getPartOfSpeech().toString());
            conceptNode.addLabel(Label.label("LanguageRepresentation"));
        }
        System.out.println("OK");
        System.out.print("Uploading VisualRepresentations... ");
        for (VisualRepresentation repr : visRepr) {
            conceptNode = graphDb.createNode();
            conceptNode.setProperty("id", repr.getId());
            conceptNode.setProperty("name", repr.getName());
            conceptNode.setProperty("mediaType", repr.getMediaType().toString());
            conceptNode.setProperty("source", repr.getSource());
            conceptNode.setProperty("uri", repr.getUri().toString());
            conceptNode.addLabel(Label.label("VisualRepresentation"));
        }
        System.out.println("OK");
        System.out.print("Uploading MotoricRepresentations... ");
        for (MotoricRepresentation repr : motRepr) {
            conceptNode = graphDb.createNode();
            conceptNode.setProperty("id", repr.getId());
            conceptNode.setProperty("performingAgent", repr.getPerformingAgent().toString());
            conceptNode.setProperty("source", repr.getSource());
            conceptNode.setProperty("uri", repr.getUri().toString());
            conceptNode.addLabel(Label.label("MotoricRepresentation"));
        }
        System.out.println("OK");
        System.out.print("Uploading Concepts with Representations... ");
        int i = 1;
        int max = concepts.size();
        int prevPerc = 0;
        for (Concept concept : concepts) {
            conceptNode = graphDb.createNode();
            conceptNode.setProperty("id", concept.getId());
            conceptNode.setProperty("name", concept.getName());
            conceptNode.setProperty("conceptType", concept.getConceptType().toString());
            conceptNode.setProperty("conceptExternalSourceId", concept.getExternalSourceId());
            conceptNode.setProperty("conceptPragmaticStatus", concept.getPragmaticStatus().toString());
            conceptNode.setProperty("conceptSpecificityLevel", concept.getSpecificityLevel().toString());
            conceptNode.setProperty("conceptUniqueInstance", concept.getUniqueInstance().toString());
            conceptNode.setProperty("conceptSource", concept.getSource());
            conceptNode.setProperty("conceptStatus", concept.getStatus().toString());
            conceptNode.addLabel(Label.label("Concept"));
            List<LanguageRepresentation> lr = concept.getLanguageRepresentations();
            for (LanguageRepresentation lrx : lr) {
                Node n = graphDb.findNodes(Label.label("LanguageRepresentation"), "id", lrx.getId()).next();
                conceptNode.createRelationshipTo(n, RelationshipType.withName("LANGUAGE_REPR"));
            }
            List<VisualRepresentation> vr = concept.getVisualRepresentations();
            for (VisualRepresentation vrx : vr) {
                Node n = graphDb.findNodes(Label.label("VisualRepresentation"), "id", vrx.getId()).next();
                conceptNode.createRelationshipTo(n, RelationshipType.withName("VISUAL_REPR"));
            }
            List<MotoricRepresentation> mr = concept.getMotoricRepresentations();
            for (MotoricRepresentation mrx : mr) {
                Node n = graphDb.findNodes(Label.label("MotoricRepresentation"), "id", mrx.getId()).next();
                conceptNode.createRelationshipTo(n, RelationshipType.withName("MOTORIC_REPR"));
            }

            int perc = new Double((i * 1.0 / max) * 100).intValue();
            if (perc > prevPerc && perc % 5 == 0) {
                prevPerc = perc;
                System.out.print(perc + "% ");
            }
            i++;
        }
        System.out.println(" OK");
        System.out.print("Uploading RelationSets... ");
        i = 1;
        max = relsets.size();
        prevPerc = 0;
        for (RelationSet rset : relsets) {
            conceptNode = graphDb.createNode();
            conceptNode.setProperty("id", rset.getId());
            conceptNode.setProperty("name", rset.getName());
            conceptNode.addLabel(Label.label("RelationSet"));
            List<Relation> rxs = rset.getRelationsSet();
            int ri = 0;
            for (Relation rx : rxs) {
                RelationArgument larg = rx.getLeftArgument();
                RelationArgument rarg = rx.getRightArgument();
                Long lid, rid;
                Node nl = null, nr = null;
                if (larg.isConcept()) {
                    lid = larg.getConcept().getId();
                    nl = graphDb.findNodes(Label.label("Concept"), "id", lid).next();
                } else if (larg.isRelationSet()) {
                    lid = larg.getRelationSet().getId();
                    nl = graphDb.findNodes(Label.label("RelationSet"), "id", lid).next();
                }
                if (rarg.isConcept()) {
                    rid = rarg.getConcept().getId();
                    nr = graphDb.findNodes(Label.label("Concept"), "id", rid).next();
                } else if (rarg.isRelationSet()) {
                    rid = rarg.getRelationSet().getId();
                    nr = graphDb.findNodes(Label.label("RelationSet"), "id", rid).next();
                }
                if (nl != null && nr != null) {
                    Relationship rsx = conceptNode.createRelationshipTo(nl,
                            RelationshipType.withName("RS_LEFT"));
                    rsx.setProperty("n", ri);
                    Relationship rsx2 = conceptNode.createRelationshipTo(nr,
                            RelationshipType.withName("RS_RIGHT"));
                    rsx2.setProperty("n", ri);
                    ri++;
                }
            }
            int perc = new Double((i * 1.0 / max) * 100).intValue();
            if (perc > prevPerc && perc % 5 == 0) {
                prevPerc = perc;
                System.out.print(perc + "% ");
            }
            i++;
        }
        System.out.println(" OK");
        System.out.print("Uploading Relations... ");
        i = 1;
        max = rels.size();
        prevPerc = 0;
        for (Relation rel : rels) {
            RelationArgument larg = rel.getLeftArgument();
            RelationArgument rarg = rel.getRightArgument();
            Long lid, rid;
            Node nl = null, nr = null;
            if (larg.isConcept()) {
                lid = larg.getConcept().getId();
                nl = graphDb.findNodes(Label.label("Concept"), "id", lid).next();
            } else if (larg.isRelationSet()) {
                lid = larg.getRelationSet().getId();
                nl = graphDb.findNodes(Label.label("RelationSet"), "id", lid).next();
            }
            if (rarg.isConcept()) {
                rid = rarg.getConcept().getId();
                nr = graphDb.findNodes(Label.label("Concept"), "id", rid).next();
            } else if (rarg.isRelationSet()) {
                rid = rarg.getRelationSet().getId();
                nr = graphDb.findNodes(Label.label("RelationSet"), "id", rid).next();
            }
            if (nl != null && nr != null) {
                Relationship rx = nl.createRelationshipTo(nr,
                        RelationshipType.withName(rel.getRelationType().getForwardNameString()));
                rx.setProperty("linguisticallySupported", rel.getLinguisticallySupported().toString());
            }

            int perc = new Double((i * 1.0 / max) * 100).intValue();
            if (perc > prevPerc && perc % 5 == 0) {
                prevPerc = perc;
                System.out.print(perc + "% ");
            }
            i++;
        }
        System.out.println(" OK");
    } catch (Error e) {
        System.out.println("Error occured: ");
        System.out.println(e.getMessage());
        System.out.println(Arrays.toString(e.getStackTrace()));
    }

    tx.success();

    if (cDao.getEntityManager().isOpen()) {
        cDao.close();
    }
    if (rDao.getEntityManager().isOpen()) {
        rDao.close();
    }
    if (lrDao.getEntityManager().isOpen()) {
        lrDao.close();
    }
    if (vrDao.getEntityManager().isOpen()) {
        vrDao.close();
    }
    if (mrDao.getEntityManager().isOpen()) {
        mrDao.close();
    }
    if (rDao.getEntityManager().isOpen()) {
        rDao.close();
    }
    if (raDao.getEntityManager().isOpen()) {
        raDao.close();
    }
    if (rsDao.getEntityManager().isOpen()) {
        rsDao.close();
    }
    if (rtDao.getEntityManager().isOpen()) {
        rtDao.close();
    }
    for (Frame frame : Frame.getFrames()) {
        frame.dispose();
    }
    tx.close();
}