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:Main.java

private static void serializeXML(Element doc, Writer writer, boolean addXmlDeclaration) throws IOException {
    try {/* ww w. j ava 2  s  .  c om*/
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer serializer = impl.createLSSerializer();
        DOMConfiguration config = serializer.getDomConfig();
        config.setParameter("xml-declaration", addXmlDeclaration);
        // config.setParameter("format-pretty-print", true);
        // config.setParameter("normalize-characters", true);
        LSOutput out = impl.createLSOutput();
        out.setCharacterStream(writer);
        serializer.write(doc, out);
    } catch (Throwable e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.panoramagl.downloaders.ssl.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    try {//from  w  w w  .j ava2  s.  co m
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null);
        return context;
    } catch (Throwable e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.mrmq.uyoutube.data.UpdateVideo.java

/**
 * Add a keyword tag to a video that the user specifies. Use OAuth 2.0 to
 * authorize the API request.// www  .j  a  v  a  2 s . c  o m
 */
public static Video updateVideo(YouTube youtube, Video newVideo) {
    Video videoResponse = null;
    try {
        Preconditions.checkNotNull(newVideo, "Video can not be null");
        Preconditions.checkNotNull(newVideo.getSnippet(), "Video snippet can not be null");

        // Call the YouTube Data API's youtube.videos.list method to
        // retrieve the resource that represents the specified video.
        YouTube.Videos.List listVideosRequest = youtube.videos().list("snippet").setId(newVideo.getId());
        VideoListResponse listResponse = listVideosRequest.execute();

        // Since the API request specified a unique video ID, the API
        // response should return exactly one video. If the response does
        // not contain a video, then the specified video ID was not found.
        List<Video> videoList = listResponse.getItems();
        if (videoList.isEmpty()) {
            logger.error("Can't find a video with ID: " + newVideo.getId());
            return null;
        }

        // Extract the snippet from the video resource.
        Video video = videoList.get(0);
        VideoSnippet snippet = video.getSnippet();

        // Preserve any tags already associated with the video. If the
        // video does not have any tags, create a new array. Append the
        // provided tag to the list of tags associated with the video.
        if (newVideo.getSnippet().getTags() != null)
            snippet.setTags(newVideo.getSnippet().getTags());
        if (!StringUtils.isEmpty(newVideo.getSnippet().getTitle()))
            snippet.setTitle(newVideo.getSnippet().getTitle());
        if (!StringUtils.isEmpty(newVideo.getSnippet().getDescription()))
            snippet.setDescription(newVideo.getSnippet().getDescription());

        // Update the video resource by calling the videos.update() method.
        YouTube.Videos.Update updateVideosRequest = youtube.videos().update("snippet", video);
        videoResponse = updateVideosRequest.execute();

        // Print information from the updated resource.
        logger.info("\n================== Returned Video ==================\n");
        logger.info("  - Title: " + videoResponse.getSnippet().getTitle());
        logger.info("  - Tags: " + videoResponse.getSnippet().getTags());
        return videoResponse;
    } catch (GoogleJsonResponseException e) {
        logger.error("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
    } catch (IOException e) {
        logger.error("IOException: " + e.getMessage(), e);
    } catch (Throwable t) {
        logger.error("Throwable: " + t.getMessage(), t);
    }

    return videoResponse;
}

From source file:com.example.HelloWorldIntegrationTest.java

@AfterClass
public static void stopSeleniumClent() {
    try {//from w  ww .  j  a  v  a2s . co  m
        driver.close();
        driver.quit();
    } catch (Throwable t) {
        // Catch error & log, not critical for tests
        System.err.println("Error stopping driver: " + t.getMessage());
        t.printStackTrace(System.err);
    }
}

From source file:com.norbl.util.StringUtil.java

public static String getExceptionMessage(Throwable x) {
    Throwable c = x.getCause();
    if ((c != null) && (c.getMessage() != null) && (c.getMessage().length() > 0)) {
        return (c.getMessage());
    } else//from ww  w  .j  ava2  s  . c o  m
        return (x.toString());
}

From source file:de.tbuchloh.kiskis.gui.systray.SystemTrayFactory.java

/**
 * @param main//from  w  w  w  .j a v  a  2s  . co m
 *            is the frame to control.
 * @return a corresponding system tray depending on the underlying os.
 */
public static ISystemTray create(final IMainFrame main) {
    try {
        return new Java6SystemTray(main);
    } catch (final Throwable e) {
        LOG.warn("Could not instantiate system tray " + "- perhaps SWT is not installed!\n" + e.getMessage());
        return new DummySystray();
    }
}

From source file:net.bpelunit.framework.control.util.BPELUnitUtil.java

/**
 * XPath exception causes tend to be deeply nested. The first meaningful exception (with an
 * error message) is some way down. Find it.
 * /* w  w  w. j a  va  2s.c  o m*/
 * @param e
 * @return
 */
public static Throwable findRootThrowable(Exception e) {
    Throwable f = e;
    while (f.getMessage() == null && f.getCause() != null) {
        f = f.getCause();
    }
    return f;
}

From source file:com.dongfang.utils.OtherUtils.java

public static void trustAllSSLForHttpsURLConnection() {
    // Create a trust manager that does not validate certificate chains
    if (trustAllCerts == null) {
        trustAllCerts = new TrustManager[] { new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }/*from  w  ww .j  av  a  2s .  co  m*/

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

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } };
    }
    // Install the all-trusting trust manager
    final SSLContext sslContext;
    try {
        sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, trustAllCerts, null);
        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
    } catch (Throwable e) {
        ULog.e(e.getMessage(), e);
    }
    HttpsURLConnection
            .setDefaultHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}

From source file:com.ycj.android.common.utils.OtherUtils.java

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

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

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        }};
    }
    // Install the all-trusting trust manager
    final SSLContext sslContext;
    try {
        sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, trustAllCerts, null);
        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
    } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
    }
    HttpsURLConnection.setDefaultHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}

From source file:com.softwarementors.extjs.djn.router.processor.standard.form.upload.FileUploadException.java

public static FileUploadException forFileUploadException(
        org.apache.commons.fileupload.FileUploadException cause) {
    assert cause != null;

    // The FileUploadException raised by commons-fileupload always
    // hides an inner exception that is the real cause
    Throwable realCause = cause.getCause();
    assert realCause != null;

    String message = "Unable to process the files to upload.";
    if (realCause.getMessage() != null) {
        message += ' ' + realCause.getMessage();
    }// ww  w.  j av  a  2  s.  com
    FileUploadException ex = new FileUploadException(message, realCause);
    return ex;
}