Example usage for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException getMessage

List of usage examples for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.commons.httpclient.contrib.proxy.PluginProxyTestApplet.java

private void detectProxy() {
    String urlString = urlTextField.getText();
    if (urlString == null || "".equals(urlString)) {
        JOptionPane.showMessageDialog(super.getRootPane(), "URL can't be empty", "Missing URL",
                JOptionPane.ERROR_MESSAGE);
        return;/*from  w  w w . jav a  2 s.  com*/
    }
    if (!urlString.startsWith("http://")) {
        urlString = "http://" + urlString;
    }
    try {
        URL url = new URL(urlString);
        HttpHost hostInfo = PluginProxyUtil.detectProxy(url);
        if (hostInfo != null) {
            hostLabel.setText(hostInfo.getHostName());
            portLabel.setText("" + hostInfo.getPort());
        } else {
            hostLabel.setText("none");
            portLabel.setText("none");
        }
        grid.validate();
    } catch (ProxyDetectionException e) {
        JOptionPane.showMessageDialog(getRootPane(), e.getMessage(), "Proxy Detection Failed",
                JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(getRootPane(), e.getMessage(), "Unexpected Exception",
                JOptionPane.ERROR_MESSAGE);
        e.printStackTrace();
    }
}