Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

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

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.judoscript.jamaica.MyUtils.java

public static String getExceptionMessage(Throwable t) {
    String msg = t.getMessage();// w  w  w.j ava  2  s  . com
    return msg != null ? msg : t.getClass().getName();
}

From source file:at.ac.univie.isc.asio.insight.VndError.java

/**
 * Create a message for the given exception - either its message if present or the class name.
 *///from   w  ww .j  a  v a2s .com
public static String labelFor(final Throwable error) {
    final String message = error.getMessage();
    return message == null ? error.getClass().getSimpleName() : message;
}

From source file:com.bstek.dorado.view.resolver.PageOutputUtils.java

public static void outputException(Writer writer, Throwable throwable) throws IOException {
    writer.append("<h1 style=\"font-size:12pt; color:red\">");
    OutputUtils.outputString(writer,/*w ww  . ja v a 2 s.c  om*/
            StringUtils.defaultString(throwable.getMessage(), throwable.getClass().getName()));
    writer.append("</h1>\n");
    writer.append("<ul>\n");
    StackTraceElement[] stes = throwable.getStackTrace();
    for (int i = 0; i < stes.length; i++) {
        StackTraceElement ste = stes[i];
        writer.append("<li>").append("at ");
        OutputUtils.outputString(writer, ste.toString());
        writer.append("</li>\n");
    }
    writer.append("</ul>\n");
}

From source file:com.seleniumtests.reporter.reporters.CommonReporter.java

/**
 * Method to generate the formated stacktrace
 * @param exception      Exception to format
 * @param title         title of the exception
 * @param contentBuffer   //from   ww w .j a  v  a 2s  .  co  m
 * @param format      format to use to encode ('html', 'csv', 'xml', 'json')
 */
public static void generateTheStackTrace(final Throwable exception, final String title,
        final StringBuilder contentBuffer, String format) {
    contentBuffer.append(exception.getClass() + ": " + StringUtility.encodeString(title, format) + "\n");

    StackTraceElement[] s1 = exception.getStackTrace();
    Throwable t2 = exception.getCause();
    if (t2 == exception) {
        t2 = null;
    }
    for (int x = 0; x < s1.length; x++) {
        String message = filterStackTrace(s1[x].toString());
        if (message != null) {
            contentBuffer.append("\nat " + StringUtility.encodeString(message, format));
        }
    }

    if (t2 != null) {
        generateTheStackTrace(t2, "Caused by " + t2.getLocalizedMessage(), contentBuffer, format);
    }
}

From source file:org.apache.atlas.web.util.Servlets.java

public static Response getErrorResponse(Throwable e, Response.Status status) {
    String message = e.getMessage() == null ? "Failed with " + e.getClass().getName() : e.getMessage();
    Response response = getErrorResponse(message, status);

    return response;
}

From source file:org.cleverbus.core.common.exception.ExceptionTranslator.java

/**
 * Returns error message for root exception.
 *
 * @param ex the exception//from  ww w . ja v  a2s  .  c  o m
 * @return exception message
 */
private static String getRootExceptionMessage(Throwable ex) {
    Assert.notNull(ex, "the ex must not be null");

    Throwable rootEx = ExceptionUtils.getRootCause(ex);
    if (rootEx == null) {
        rootEx = ex;
    }

    return rootEx.getClass().getSimpleName() + ": " + rootEx.getMessage();
}

From source file:com.screenslicer.common.Log.java

public static void exception(Throwable t, String supplementaryMessage) {
    if (logger == null) {
        init("screenslicer", true);
    }/*from   w w  w  .  j  av  a 2s.c om*/
    Level level = Level.SEVERE;
    String packageName = t.getClass().getName();
    for (int i = 0; i < chattyClasses.length; i++) {
        if (packageName.startsWith(chattyClasses[i])) {
            level = Level.FINE;
            break;
        }
    }
    String message = t.getMessage();
    message = CommonUtil.isEmpty(message) ? "" : message;
    logger.log(level,
            "Exception \"" + message + "\" ~ "
                    + (CommonUtil.isEmpty(supplementaryMessage) ? "" : (supplementaryMessage + " ~ "))
                    + "Stack trace: " + ExceptionUtils.getStackTrace(t));
}

From source file:com.heliosdecompiler.helios.Helios.java

public static void displayError(Throwable t) {
    t.printStackTrace();//  w ww .jav  a 2 s . c  om
    StringWriter writer = new StringWriter();
    t.printStackTrace(new PrintWriter(writer));
    JOptionPane.showMessageDialog(null, writer.toString(), t.getClass().getSimpleName(),
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:com.cisco.dvbu.ps.common.util.CompositeLogger.java

/**
 * log information about the passed in soap fault
 * //from w  w w.  j  a v a  2 s .c  om
 * @param e exception to be logged (ignore if null)
 * @param logMessage detailed message to be logged (can be null). 
 * @param SoapFault Fault Object contains additional information about the issue to help the developer in diagnosing the problem
 */
public static void logException(Throwable ex, String logMessage, Fault f) {

    logException(ex, logMessage);

    if (f.getErrorEntry() != null) {
        logger.error("\n" + ex.getClass().getName()
                + " ------------------- MessageEntry Begin -------------------\n");
        logger.error(getFaultException(ex, f));
        logger.error(ex.getClass().getName() + " ------------------- MessageEntry End -------------------\n");
    }

}

From source file:co.paralleluniverse.photon.Photon.java

private static void markError(final Meter errorsMeter, final Map<String, AtomicInteger> errors,
        final Throwable t) {
    errorsMeter.mark();//from   w w  w . j a va 2  s  .c  om
    if (t != null) {
        errors.putIfAbsent(t.getClass().getName(), new AtomicInteger());
        errors.get(t.getClass().getName()).incrementAndGet();
    }
}