Example usage for java.lang Throwable getMessage

List of usage examples for java.lang Throwable getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

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

public static String getExceptionMessage(Throwable t) {
    String msg = t.getMessage();
    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.
 *//*  ww w.  j av  a2s .  com*/
public static String labelFor(final Throwable error) {
    final String message = error.getMessage();
    return message == null ? error.getClass().getSimpleName() : message;
}

From source file:gov.nih.nci.evs.reportwriter.test.lexevs.Util.java

/**
 * Outputs messages to the error log and console, with additional tagging to
 * assist servicability./*from  ww  w. j  a  v a2s .c o m*/
 * 
 * @param message
 *            The message to display.
 * @param cause
 *            Error associated with the message.
 */
static void displayAndLogError(String message, Throwable cause) {
    displayTaggedMessage(message);
    if (cause.getMessage() != null) {
        displayTaggedMessage(cause.getMessage());
    }
    _logger.error(message, cause);
}

From source file:com.microsoft.alm.plugin.idea.utils.IdeaHelper.java

/**
 * Shows an error dialog//from   www  .j  av  a  2  s. c  o m
 *
 * @param project
 * @param throwable
 */
public static void showErrorDialog(@NotNull final Project project, final Throwable throwable) {
    if (throwable != null) {
        Messages.showErrorDialog(project, throwable.getMessage(),
                TfPluginBundle.message(TfPluginBundle.KEY_TITLE_TEAM_SERVICES_ERROR));
    } else {
        Messages.showErrorDialog(project,
                TfPluginBundle.message(TfPluginBundle.KEY_MESSAGE_TEAM_SERVICES_UNEXPECTED_ERROR),
                TfPluginBundle.message(TfPluginBundle.KEY_TITLE_TEAM_SERVICES_ERROR));
    }
}

From source file:com.webbfontaine.valuewebb.action.fcvr.FCVRSendScheduler.java

private static boolean isLoginProblem(Throwable t) {
    return t != null && "Exception at login".equals(t.getMessage());
}

From source file:com.espertech.esper.support.util.SupportMessageAssertUtil.java

public static void assertMessage(Throwable ex, String message) {
    if (message.equals("skip")) {
        return; // skip message validation
    }/*w  ww  .j  a va 2  s.  c o m*/
    if (message.length() > 10) {
        log.error("Exception: " + ex.getMessage(), ex);
        if (!ex.getMessage().startsWith(message)) {
            Assert.fail("\nExpected:" + message + "\nReceived:" + ex.getMessage());
        }
    } else {
        log.error("Exception: " + ex.getMessage(), ex);
        Assert.fail("No assertion provided, received: " + ex.getMessage());
    }
}

From source file:com.aliyun.oss.common.utils.ExceptionFactory.java

public static OSSException createInvalidResponseException(String requestId, Throwable cause) {
    return createInvalidResponseException(requestId,
            COMMON_RESOURCE_MANAGER.getFormattedString("FailedToParseResponse", cause.getMessage()));
}

From source file:com.aliyun.oss.common.utils.ExceptionFactory.java

public static OSSException createInvalidResponseException(String requestId, String rawResponseError,
        Throwable cause) {
    return createInvalidResponseException(requestId,
            COMMON_RESOURCE_MANAGER.getFormattedString("FailedToParseResponse", cause.getMessage()),
            rawResponseError);/*w w w .j ava  2s . c  o m*/
}

From source file:com.prime.app.agvirtual.web.jsf.component.selectinputtext.UfDictionary.java

/**
 * Generates a short list of cities that match the given searchWord. The
 * length of the list is specified by the maxMatches attribute.
 * /*  w ww.  j av  a 2 s  .c o m*/
 * @param searchWord
 *            city name to search for
 * @param maxMatches
 *            max number of possibilities to return
 * @return list of SelectItem objects which contain potential city names.
 */
public static ArrayList generateCityMatches(String searchWord, int maxMatches) {

    ArrayList matchList = new ArrayList(maxMatches);

    // ensure the autocomplete search word is present
    if ((searchWord == null) || (searchWord.trim().length() == 0)) {
        return matchList;
    }

    try {
        SelectItem searchItem = new SelectItem("", searchWord);
        int insert = Collections.binarySearch(ufDictionary, searchItem, LABEL_COMPARATOR);

        // less then zero if we have a partial match
        if (insert < 0) {
            insert = Math.abs(insert) - 1;
        } else {
            // If there are duplicates in a list, ensure we start from the
            // first one
            if (insert != ufDictionary.size()
                    && LABEL_COMPARATOR.compare(searchItem, ufDictionary.get(insert)) == 0) {
                while (insert > 0 && LABEL_COMPARATOR.compare(searchItem, ufDictionary.get(insert - 1)) == 0) {
                    insert = insert - 1;
                }
            }
        }

        for (int i = 0; i < maxMatches; i++) {
            // quit the match list creation if the index is larger than
            // max entries in the cityDictionary if we have added
            // maxMatches.
            if ((insert + i) >= ufDictionary.size() || i >= maxMatches) {
                break;
            }
            matchList.add(ufDictionary.get(insert + i));
        }
    } catch (Throwable e) {
        log.error(e.getMessage());

    }
    // assign new matchList
    return matchList;
}

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;
}