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:com.bstek.dorado.util.clazz.ClassUtils.java

@SuppressWarnings("rawtypes")
public static Class forName(String className) throws ClassNotFoundException {
    try {/*from  w  w  w  .j  a  v  a2 s . c  om*/
        return org.apache.commons.lang.ClassUtils.getClass(className);
    } catch (Error e) {
        throw new ClassNotFoundException(e.getMessage(), e);
    }
}

From source file:org.apache.cocoon.template.script.event.TextEvent.java

protected static void characters(ExpressionContext expressionContext, ExecutionContext executionContext,
        TextEvent event, CharHandler handler) throws SAXException {
    Iterator iter = event.getSubstitutions().iterator();
    while (iter.hasNext()) {
        Object subst = iter.next();
        char[] chars;
        if (subst instanceof Literal) {
            chars = ((Literal) subst).getCharArray();
        } else {/*from  w  w  w.  j a v a2 s.  co m*/
            JXTExpression expr = (JXTExpression) subst;
            try {
                Object val = expr.getValue(expressionContext);
                chars = val != null ? val.toString().toCharArray() : ArrayUtils.EMPTY_CHAR_ARRAY;
            } catch (Exception e) {
                throw new SAXParseException(e.getMessage(), event.getLocation(), e);
            } catch (Error err) {
                throw new SAXParseException(err.getMessage(), event.getLocation(), new ErrorHolder(err));
            }
        }
        handler.characters(chars, 0, chars.length);
    }
}

From source file:net.pms.util.SystemInformation.java

/**
 * Collects and returns system information.
 *
 * @return A {@link List} of {@link String}s containing the collected system
 *         information./*  w w  w  .ja  v  a2 s . c  o m*/
 */
public static List<String> getSystemInfo() {
    List<String> result = new ArrayList<>();
    StringBuilder sb = new StringBuilder();
    long jvmMemory = Runtime.getRuntime().maxMemory();
    OperatingSystem os = null;
    CentralProcessor processor = null;
    GlobalMemory memory = null;
    try {
        SystemInfo systemInfo = new SystemInfo();
        HardwareAbstractionLayer hardware = systemInfo.getHardware();
        os = systemInfo.getOperatingSystem();
        processor = hardware.getProcessor();
        memory = hardware.getMemory();
    } catch (Error e) {
        LOGGER.debug("Could not retrieve system information: {}", e.getMessage());
        LOGGER.trace("", e);
    }

    sb.append("JVM: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.version")).append(" (")
            .append(System.getProperty("sun.arch.data.model")).append("-bit) by ")
            .append(System.getProperty("java.vendor"));
    result.add(sb.toString());
    sb.setLength(0);
    sb.append("OS: ");
    if (os != null && isNotBlank(os.toString())) {
        sb.append(os.toString()).append(" ").append(getOSBitness()).append("-bit");
    } else {
        sb.append(System.getProperty("os.name")).append(" ").append(getOSBitness()).append("-bit ");
        sb.append(System.getProperty("os.version"));
    }
    result.add(sb.toString());
    sb.setLength(0);
    if (processor != null) {
        sb.append("CPU: ").append(processor.getName()).append(" with ")
                .append(processor.getPhysicalProcessorCount());
        if (processor.getPhysicalProcessorCount() > 1) {
            sb.append(" cores");
        } else {
            sb.append(" core");
        }
        if (processor.getLogicalProcessorCount() != processor.getPhysicalProcessorCount()) {
            sb.append(" (").append(processor.getLogicalProcessorCount());
            if (processor.getLogicalProcessorCount() > 1) {
                sb.append(" virtual cores)");
            } else {
                sb.append(" virtual core)");
            }
        }
        result.add(sb.toString());
        sb.setLength(0);
    }
    if (memory != null) {
        sb.append("Physical Memory: ").append(StringUtil.formatBytes(memory.getTotal(), true));
        result.add(sb.toString());
        sb.setLength(0);
        sb.append("Free Memory: ").append(StringUtil.formatBytes(memory.getAvailable(), true));
        result.add(sb.toString());
        sb.setLength(0);

    }
    sb.append("Maximum JVM Memory: ");
    if (jvmMemory == Long.MAX_VALUE) {
        sb.append("Unlimited");
    } else {
        sb.append(StringUtil.formatBytes(jvmMemory, true));
    }
    result.add(sb.toString());
    return result;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsg.CFAccXMsgSchemaMessageFormatter.java

public static String formatRspnException(String separator, Error e) {
    String retval = "<RspnException "
            + CFLibXmlUtil.formatRequiredXmlString(null, "Name", e.getClass().getName())
            + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", e.getMessage()) + " />";
    return (retval);
}

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

/**
 * Creates the print format of the Error message.
 * //w  w w . jav a2 s  .c o m
 * @param result
 *          the result
 * @return String
 */
public static String createErrorMessage(SaveResult result) {
    StringBuilder resultString = new StringBuilder("Error Message :\n");
    if (result != null && !result.getSuccess()) {
        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:com.zuora.api.util.ZuoraUtility.java

/**
 * Creates the print format of the Error message.
 * /*w ww.  j  a v  a2  s. co  m*/
 * @param result
 *          the AmendResult
 * @return String
 */
public static String createErrorMessage(AmendResult result) {
    StringBuilder resultString = new StringBuilder("Error Message :\n");
    if (result != null && !result.getSuccess()) {
        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:com.zuora.api.util.ZuoraUtility.java

/**
 * Creates the error message./*from www .j  a  v a2 s  . c  om*/
 * 
 * @param result
 *          the result
 * @return the string
 */
public static String createErrorMessage(DeleteResult result) {
    StringBuilder resultString = new StringBuilder("Error Message :\n");
    if (result != null && !result.getSuccess()) {
        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:com.zuora.api.util.ZuoraUtility.java

/**
 * Creates the print format of the Error message.
 * /* w w  w. j  ava  2 s.  c  om*/
 * @param result
 *          the SubscribeResult
 * @return String
 */
public static String createErrorMessage(SubscribeResult result) {
    StringBuilder resultString = new StringBuilder("Error Message :\n");
    if (result != null && !result.getSuccess()) {
        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:us.paulevans.basicxslt.Utils.java

/**
 * Error handler - displays exception stack trace in a 
 * ValidationErrorFrame./*ww  w  .  j  av a  2s  . c o m*/
 * @param aTitle
 * @param aHeaderLabel
 * @param aHeader
 * @param aFileName
 * @param aParent
 * @param aThrowable
 * @throws IOException
 */
public static void handleXMLError(String aTitle, String aHeaderLabel, String aHeader, String aFileName,
        BasicXSLTFrame aParent, Throwable aThrowable) {

    Error error;

    logger.info("XML error: " + aThrowable.getMessage());
    error = getErrorDetail(aThrowable);
    new ValidationErrorFrame(aParent, aTitle, aHeaderLabel, aHeader, error.getColumn(), error.getLine(),
            error.getMessage(), aFileName, null);
}

From source file:com.indivica.olis.Driver.java

public static void readResponseFromXML(HttpServletRequest request, String olisResponse) {

    olisResponse = olisResponse.replaceAll("<Content", "<Content xmlns=\"\" ");
    olisResponse = olisResponse.replaceAll("<Errors", "<Errors xmlns=\"\" ");

    try {/*ww w .  ja va2 s  . c o m*/
        DocumentBuilderFactory.newInstance().newDocumentBuilder();
        SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

        Source schemaFile = new StreamSource(
                new File(OscarProperties.getInstance().getProperty("olis_response_schema")));
        factory.newSchema(schemaFile);

        JAXBContext jc = JAXBContext.newInstance("ca.ssha._2005.hial");
        Unmarshaller u = jc.createUnmarshaller();
        @SuppressWarnings("unchecked")
        Response root = ((JAXBElement<Response>) u.unmarshal(new InputSource(new StringReader(olisResponse))))
                .getValue();

        if (root.getErrors() != null) {
            List<String> errorStringList = new LinkedList<String>();

            // Read all the errors
            ArrayOfError errors = root.getErrors();
            List<ca.ssha._2005.hial.Error> errorList = errors.getError();

            for (ca.ssha._2005.hial.Error error : errorList) {
                String errorString = "";
                errorString += "ERROR " + error.getNumber() + " (" + error.getSeverity() + ") : "
                        + error.getMessage();
                MiscUtils.getLogger().debug(errorString);

                ArrayOfString details = error.getDetails();
                if (details != null) {
                    List<String> detailList = details.getString();
                    for (String detail : detailList) {
                        errorString += "\n" + detail;
                    }
                }

                errorStringList.add(errorString);
            }
            if (request != null)
                request.setAttribute("errors", errorStringList);
        } else if (root.getContent() != null) {
            if (request != null)
                request.setAttribute("olisResponseContent", root.getContent());
        }
    } catch (Exception e) {
        MiscUtils.getLogger().error("Couldn't read XML from OLIS response.", e);

        LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);
        notifyOlisError(loggedInInfo.getLoggedInProvider(), "Couldn't read XML from OLIS response." + "\n" + e);
    }
}