Example usage for java.lang Error getClass

List of usage examples for java.lang Error getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

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:org.fornax.cartridges.sculptor.framework.errorhandling.BasicErrorHandlingAdvice.java

protected void handleError(Object target, Error e) {
    Logger log = LoggerFactory.getLogger(target.getClass());
    String errorCode = e.getClass().getName();
    String mappedErrorCode = mapLogCode(errorCode);
    LogMessage message = new LogMessage(mappedErrorCode, excMessage(e));
    log.error(message.toString(), e);/*from  w w w . ja  v a  2 s. co m*/
}

From source file:net.darkmist.clf.LogParser.java

private String[] parseParts(String line) throws LogFormatException {
    Matcher matcher;/*from w  ww .j  ava 2s. co  m*/

    try {
        if (cachedMatcher == null)
            cachedMatcher = PATTERN_NO_SP.matcher(line);
        else
            cachedMatcher.reset(line);
        if (cachedMatcher.matches())
            return matcher2parts(cachedMatcher);

        // any special handling here...
        /*
        matcher = PATTERN_NO_SP.matcher(line);
        if(matcher.matches())
        {
           if(logger.isDebugEnabled())
              logger.debug("PATTERN_NO_SP match: " + line);
           return matcher2parts(matcher);
        }
        */

        // this is happening more than the back track below...
        matcher = PATTERN_BM.matcher(line);
        if (matcher.matches()) { // since there is no proto, we need to provide one
            String[] parts;

            //if(logger.isDebugEnabled())
            //logger.debug("PATTERN_BM match: " + line);

            parts = new String[NUM_PARTS];
            for (int i = 0; i < PART_PROTO; i++)
                parts[i] = matcher.group(i);
            parts[PART_PROTO] = null;
            for (int i = PART_STATUS; i < NUM_PARTS; i++)
                parts[i] = matcher.group(i - 1);
            return parts;
        }

        matcher = PATTERN_BACK_TRACK.matcher(line);
        if (matcher.matches()) {
            if (logger.isDebugEnabled())
                logger.debug("PATTERN_BACKTRACK match: " + line);
            return matcher2parts(matcher);
        }

        throw new LogFormatException("Line did not match any regex: " + line);
    } catch (Error e) { // log the line that triggered the Error
        logger.error("rethrowing Error " + e.getClass().getName() + " caused by: " + line);
        throw e;
    } catch (RuntimeException e) { // log the line that triggered the RuntimeException
        logger.error("rethrowing RuntimeException " + e.getClass().getName() + " caused by: " + line);
        throw e;
    }
}

From source file:com.gs.collections.impl.test.Verify.java

public static void assertError(Class<? extends Error> expectedErrorClass, Runnable code) {
    try {//from  w w w  .ja v a2 s  .  co m
        code.run();
    } catch (Error ex) {
        try {
            Assert.assertSame("Caught error of type <" + ex.getClass().getName() + ">, expected one of type <"
                    + expectedErrorClass.getName() + '>', expectedErrorClass, ex.getClass());
            return;
        } catch (AssertionError e) {
            Verify.throwMangledException(e);
        }
    }

    try {
        Assert.fail("Block did not throw an error of type " + expectedErrorClass.getName());
    } catch (AssertionError e) {
        Verify.throwMangledException(e);
    }
}

From source file:org.apache.solr.core.SolrResourceLoader.java

public <T> T newInstance(String cName, Class<T> expectedType, String[] subPackages, Class[] params,
        Object[] args) {/*from www.j a  va 2s .co m*/
    Class<? extends T> clazz = findClass(cName, expectedType, subPackages);
    if (clazz == null) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "Can not find class: " + cName + " in " + classLoader);
    }

    T obj = null;
    try {

        Constructor<? extends T> constructor = clazz.getConstructor(params);
        obj = constructor.newInstance(args);

    } catch (Error err) {
        log.error("Loading Class " + cName + " (" + clazz.getName() + ") triggered serious java error: "
                + err.getClass().getName(), err);
        throw err;

    } catch (Exception e) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
                "Error instantiating class: '" + clazz.getName() + "'", e);
    }

    if (!live) {
        if (obj instanceof SolrCoreAware) {
            assertAwareCompatibility(SolrCoreAware.class, obj);
            waitingForCore.add((SolrCoreAware) obj);
        }
        if (obj instanceof ResourceLoaderAware) {
            assertAwareCompatibility(ResourceLoaderAware.class, obj);
            waitingForResources.add((ResourceLoaderAware) obj);
        }
        if (obj instanceof SolrInfoMBean) {
            //TODO: Assert here?
            infoMBeans.add((SolrInfoMBean) obj);
        }
    }

    return obj;
}

From source file:ponzu.impl.test.Verify.java

public static void assertError(Class<? extends Error> expectedErrorClass, Runnable code) {
    try {/*from w ww .  j a va2s . co m*/
        code.run();
    } catch (Error ex) {
        try {
            Assert.assertSame("Caught error of type <" + ex.getClass().getName() + ">, expected one of type <"
                    + expectedErrorClass.getName() + '>', expectedErrorClass, ex.getClass());
            return;
        } catch (AssertionError e) {
            throwMangledException(e);
        }
    }

    try {
        Assert.fail("Block did not throw an error of type " + expectedErrorClass.getName());
    } catch (AssertionError e) {
        throwMangledException(e);
    }
}