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.medallia.tiny.string.StringTemplateBuilder.java

/** Throws RuntimeException if the given string is not a valid StringTemplate */
public static void verifyValidTemplate(String template) {
    StringTemplate st = st("");
    st.setErrorListener(new StringTemplateErrorListener() {
        public void error(String s, Throwable ex) {
            // dig deep for a reasonable error string
            Throwable last = null;
            for (Throwable t = ex; t != null; t = t.getCause())
                last = t;//from  w w w  . j  a va  2 s .c  om
            throw new RuntimeException(last != null ? last.getMessage() : s, ex);
        }

        public void warning(String s) {
            throw new RuntimeException(s);
        }
    });
    st.setTemplate(template);
}

From source file:www.ht.com.app.tools.OtherUtils.java

public static void trustAllHttpsURLConnection() {
    // Create a trust manager that does not validate certificate chains
    if (sslSocketFactory == null) {
        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
            @Override//w ww.ja  va  2s.c  om
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            @Override
            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } };
        try {
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, trustAllCerts, null);
            sslSocketFactory = sslContext.getSocketFactory();
        } catch (Throwable e) {
            Logger.e(e.getMessage(), e);
        }
    }

    if (sslSocketFactory != null) {
        HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
        HttpsURLConnection.setDefaultHostnameVerifier(
                org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
}

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

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

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

public static ClientException createNetworkException(IOException ex) {
    String requestId = "Unknown";
    String errorCode = ClientErrorCode.UNKNOWN;

    if (ex instanceof SocketTimeoutException) {
        errorCode = ClientErrorCode.SOCKET_TIMEOUT;
    } else if (ex instanceof SocketException) {
        errorCode = ClientErrorCode.SOCKET_EXCEPTION;
    } else if (ex instanceof ConnectTimeoutException) {
        errorCode = ClientErrorCode.CONNECTION_TIMEOUT;
    } else if (ex instanceof UnknownHostException) {
        errorCode = ClientErrorCode.UNKNOWN_HOST;
    } else if (ex instanceof HttpHostConnectException) {
        errorCode = ClientErrorCode.CONNECTION_REFUSED;
    } else if (ex instanceof ClientProtocolException) {
        Throwable cause = ex.getCause();
        if (cause instanceof NonRepeatableRequestException) {
            errorCode = ClientErrorCode.NONREPEATABLE_REQUEST;
            return new ClientException(cause.getMessage(), errorCode, requestId, cause);
        }//  w ww.j  a va  2s .  c om
    }

    return new ClientException(ex.getMessage(), errorCode, requestId, ex);
}

From source file:avantssar.aslanpp.testing.Tester.java

private static void reportException(String message, Throwable e, PrintStream out) {
    out.print("Error: ");
    out.println(message);//from w w  w.  j  a  v  a  2  s. co  m
    out.println(e.getMessage());
    out.println();
    Debug.logger.fatal(message, e);
}

From source file:com.addbean.autils.tools.OtherUtils.java

public static Charset getCharsetFromHttpRequest(final HttpRequestBase request) {
    if (request == null)
        return null;
    String charsetName = null;/* w ww.j a  v a  2s .c o m*/
    Header header = request.getFirstHeader("Content-Type");
    if (header != null) {
        for (HeaderElement element : header.getElements()) {
            NameValuePair charsetPair = element.getParameterByName("charset");
            if (charsetPair != null) {
                charsetName = charsetPair.getValue();
                break;
            }
        }
    }

    boolean isSupportedCharset = false;
    if (!TextUtils.isEmpty(charsetName)) {
        try {
            isSupportedCharset = Charset.isSupported(charsetName);
        } catch (Throwable e) {
            Log.e("OtherUtils", e.getMessage());
        }
    }

    return isSupportedCharset ? Charset.forName(charsetName) : null;
}

From source file:cn.isif.util_plus.util.OtherUtils.java

public static void trustAllHttpsURLConnection() {
    // Create a trust manager that does not validate certificate chains
    if (sslSocketFactory == null) {
        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
            @Override//from w  w  w. ja  v  a  2s  .c  o  m
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            @Override
            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } };
        try {
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, trustAllCerts, null);
            sslSocketFactory = sslContext.getSocketFactory();
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
        }
    }

    if (sslSocketFactory != null) {
        HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
        HttpsURLConnection.setDefaultHostnameVerifier(
                org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
}

From source file:controllers.modules.cas.SecureCAS.java

/**
 * ?//from  w w  w. j a v  a  2  s. co m
 */
@Before(priority = 50)
public static void checkLoginStatus() {
    if (session.contains(USERNAME)) {
        String username = session.get(USERNAME);
        String logoutTagKey = LOGOUT_TAG + "_" + username;
        if (Cache.get(logoutTagKey) != null) {
            try {
                doLogout();
            } catch (Throwable throwable) {
                Logger.warn(throwable.getMessage());
            } finally {
                Cache.delete(logoutTagKey);
            }
            Logger.debug("%s is logout ", username);
        }
    }
}

From source file:net.sf.groovyMonkey.GroovyMonkeyPlugin.java

public static void logExceptionInfo(final Throwable throwable) {
    logExceptionInfo(throwable.getMessage(), throwable);
}

From source file:net.tatans.rhea.network.view.OtherUtils.java

public static void trustAllHttpsURLConnection() {
    // Create a trust manager that does not validate certificate chains
    if (sslSocketFactory == null) {
        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
            @Override/*from ww w . j a v  a2 s  .  c o m*/
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            @Override
            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } };
        try {
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, trustAllCerts, null);
            sslSocketFactory = sslContext.getSocketFactory();
        } catch (Throwable e) {
            TatansLogUtils.e(e.getMessage(), e);
        }
    }

    if (sslSocketFactory != null) {
        HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
        HttpsURLConnection.setDefaultHostnameVerifier(
                org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
}