Example usage for java.lang Exception toString

List of usage examples for java.lang Exception toString

Introduction

In this page you can find the example usage for java.lang Exception toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.cisco.oss.foundation.http.apache.ApacheHttpClientFactory.java

public static HttpClient<HttpRequest, ApacheHttpResponse> createHttpClient(String apiName,
        LoadBalancerStrategy.STRATEGY_TYPE highAvailabilityStrategyType, Configuration configuration,
        boolean enableLoadBalancing, HostnameVerifier hostnameVerifier) {
    try {//  ww  w  .  j  av a  2  s  . com
        HttpClient client = null;
        if (highAvailabilityStrategyType == null) {
            client = new ApacheHttpClient(apiName, configuration, enableLoadBalancing, hostnameVerifier);
        } else {
            client = new ApacheHttpClient(apiName, highAvailabilityStrategyType, configuration,
                    enableLoadBalancing, hostnameVerifier);
        }
        return client;
    } catch (Exception e) {
        throw new ClientException(e.toString(), e);
    }

}

From source file:com.cisco.oss.foundation.http.netlifx.apache.ApacheNetflixHttpClientFactory.java

public static HttpClient<HttpRequest, ApacheNetflixHttpResponse> createHttpClient(String apiName,
        LoadBalancerStrategy.STRATEGY_TYPE highAvailabilityStrategyType, Configuration configuration,
        boolean enableLoadBalancing, HostnameVerifier hostnameVerifier) {
    try {/*from w  w  w  .  ja  v a  2 s. co m*/
        HttpClient client = null;
        if (highAvailabilityStrategyType == null) {
            client = new ApacheNetflixHttpClient(apiName, configuration, enableLoadBalancing, hostnameVerifier);
        } else {
            client = new ApacheNetflixHttpClient(apiName, highAvailabilityStrategyType, configuration,
                    enableLoadBalancing, hostnameVerifier);
        }
        return client;
    } catch (Exception e) {
        throw new ClientException(e.toString(), e);
    }

}

From source file:Main.java

/**
 * Creates a sub-menu for changing Look'n'Feel.
 * @param rootComponent the root component which Look'n'Feel should be changed (child component are processed recursively).
 * @return a menu item with sub-menu items for each Look'n'Feel
 * installed in the system with associated actions to change the
 * Look'n'Feel for the <code>rootComponent</root>.
 *//*from   w  w  w  . j  a va2 s  . c  o  m*/
public static JMenu getLafMenu(final Component rootComponent) {
    JMenu jMenu = new JMenu("Look & Feel");
    ButtonGroup buttonGroup = new ButtonGroup();
    final UIManager.LookAndFeelInfo[] installedLFs = UIManager.getInstalledLookAndFeels();
    String currentLF = UIManager.getLookAndFeel().getName();
    for (int i = 0; i < installedLFs.length; i++) {
        JCheckBoxMenuItem jMenuItem = new JCheckBoxMenuItem(installedLFs[i].getName());
        jMenu.add(jMenuItem);
        buttonGroup.add(jMenuItem);
        jMenuItem.setState(currentLF.equals(installedLFs[i].getName()));
        class ChangeLF extends AbstractAction {
            private UIManager.LookAndFeelInfo iLF;

            public ChangeLF(UIManager.LookAndFeelInfo iLF) {
                super(iLF.getName());
                this.iLF = iLF;
            }

            public void actionPerformed(ActionEvent e) {
                try {
                    UIManager.setLookAndFeel(iLF.getClassName());
                    SwingUtilities.updateComponentTreeUI(rootComponent);
                } catch (Exception ex) {
                    System.out.print("Could not set look and feel: " + ex.toString());
                }
            }
        }
        jMenuItem.setAction(new ChangeLF(installedLFs[i]));
    }
    return jMenu;
}

From source file:BareBonesBrowserLaunch.java

/**
 * Opens the specified web page in the user's default browser
 * // w  w  w  .  j  a va  2  s .c  o  m
 * @param url
 *            A web address (URL) of a web page (ex:
 *            "http://www.google.com/")
 */
public static void openURL(String url) {
    try {
        // attempt to use Desktop library from JDK 1.6+
        Class<?> d = Class.forName("java.awt.Desktop");
        d.getDeclaredMethod("browse", new Class[] { java.net.URI.class }).invoke(
                d.getDeclaredMethod("getDesktop").invoke(null), new Object[] { java.net.URI.create(url) });
        // above code mimicks: java.awt.Desktop.getDesktop().browse()
    } catch (Exception ignore) {
        // library not available or failed
        String osName = System.getProperty("os.name");
        try {
            if (osName.startsWith("Mac OS")) {
                Class.forName("com.apple.eio.FileManager")
                        .getDeclaredMethod("openURL", new Class[] { String.class })
                        .invoke(null, new Object[] { url });
            } else if (osName.startsWith("Windows")) {
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
            } else { // assume Unix or Linux
                String browser = null;
                for (String b : browsers)
                    if (browser == null && Runtime.getRuntime().exec(new String[] { "which", b })
                            .getInputStream().read() != -1)
                        Runtime.getRuntime().exec(new String[] { browser = b, url });
                if (browser == null)
                    throw new Exception(Arrays.toString(browsers));
            }
        } catch (Exception e) {
            throw new RuntimeException(errMsg + "\n" + e.toString());
        }
    }
}

From source file:by.stub.Main.java

private static void startStubby4jUsingCommandLineArgs() {
    try {/*from  w w w  .j  av  a2 s . c o m*/
        final Map<String, String> commandLineArgs = CommandLineInterpreter.getCommandlineParams();
        final String yamlConfigFilename = commandLineArgs.get(CommandLineInterpreter.OPTION_CONFIG);

        ANSITerminal.muteConsole(CommandLineInterpreter.isMute());

        final JettyManagerFactory factory = new JettyManagerFactory();
        final JettyManager jettyManager = factory.construct(yamlConfigFilename, commandLineArgs);
        jettyManager.startJetty();

    } catch (final Exception ex) {
        final String msg = String.format("Could not init stubby4j, error: %s", ex.toString());

        throw new Stubby4JException(msg, ex);
    }
}

From source file:classes.connectionPool.java

public static void start_BasicDataSourceFactory() {
    Properties propiedades = new Properties();
    /*/*  w w w.  java  2  s  .  c o  m*/
    setMaxActive(): N mx de conexiones que se pueden abrir simultneamente.
    setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms.
    setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando.
    */

    propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver");
    propiedades.setProperty("url", "jdbc:mysql://127.0.0.1:3306/bbdd_admin");
    propiedades.setProperty("maxActive", "10");
    propiedades.setProperty("maxIdle", "8");
    propiedades.setProperty("minIdle", "0");
    propiedades.setProperty("maxWait", "500");
    propiedades.setProperty("initialSize", "5");
    propiedades.setProperty("defaultAutoCommit", "true");
    propiedades.setProperty("username", "root");
    propiedades.setProperty("password", "");
    propiedades.setProperty("validationQuery", "select 1");
    propiedades.setProperty("validationQueryTimeout", "100");
    propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2");
    propiedades.setProperty("poolPreparedStatements", "true");
    propiedades.setProperty("maxOpenPreparedStatements", "10");

    try {
        dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:Main.java

protected static synchronized InputStream getAWebPage(URL url) throws ClientProtocolException, IOException {
    HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();
    HttpGet httpGet = new HttpGet(url.toString());
    try {//from   w w w .  j a  v  a  2s.  c o  m
        //do the request
        HttpResponse response = httpClient.execute(httpGet, localContext);
        StatusLine status = response.getStatusLine();
        if (status.getStatusCode() != HTTP_STATUS_OK) {
            throw new IOException("Invalid response from the IKSU server! " + status.toString());
        }
        //InputStream ist = response.getEntity().getContent();

        return response.getEntity().getContent();
    } catch (Exception e) {
        e.printStackTrace();
        throw new ClientProtocolException("Protocol Exception! " + e.toString());
    }
}

From source file:Main.java

/**
 * Return camera instance/*from w w w  . j a v  a2  s.c om*/
 */
public static Camera getCameraInstance(int displayOrientation) {
    Camera cam = null;
    try {
        cam = Camera.open();

        // More efficient way to find available cameras. Nexus 7 needs this.
        if (cam == null) {
            int availableCameras = Camera.getNumberOfCameras();
            for (int i = 0; i < availableCameras; i++) {
                cam = Camera.open(i);
                if (cam != null)
                    break;
            }
        }

        cam.setDisplayOrientation(displayOrientation);
        Log.d(TAG, "Getting Camera: " + cam.toString());
    } catch (Exception e) {
        Log.e(TAG, "Camera is not available (in use or does not exist)");
        Log.e(TAG, e.toString());
    }
    return cam;
}

From source file:com.krawler.esp.utils.HttpPost.java

public static String GetResponse(String postdata) {
    try {/*from   w  ww .  ja  v a  2s . c  om*/
        String s = URLEncoder.encode(postdata, "UTF-8");
        // URL u = new URL("http://google.com");
        URL u = new URL("http://localhost:7070/service/soap/");
        URLConnection uc = u.openConnection();
        uc.setDoOutput(true);
        uc.setDoInput(true);
        uc.setAllowUserInteraction(false);

        DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());

        // The POST line
        dstream.writeBytes(s);
        dstream.close();

        // Read Response
        InputStream in = uc.getInputStream();
        int x;
        while ((x = in.read()) != -1) {
            System.out.write(x);
        }
        in.close();

        BufferedReader r = new BufferedReader(new InputStreamReader(in));
        StringBuffer buf = new StringBuffer();
        String line;
        while ((line = r.readLine()) != null) {
            buf.append(line);
        }
        return buf.toString();
    } catch (Exception e) {
        // throw e;
        return e.toString();
    }
}

From source file:de.cbb.mplayer.mapping.MappingUtil.java

private static void mapFieldToPresenter(Field field, Object entity, Object presenter) {
    if (MappingFactory.EXCLUSIONS.contains(field.getName())) {
        return;/*from  w  w  w. j  a  v  a2  s  .c o m*/
    }
    try {
        Object value1 = PropertyUtils.getSimpleProperty(entity, field.getName());
        String fieldname = field.getName();

        MappingFactory.buildMapper(presenter, fieldname, value1).map(value1);

    } catch (Exception ex) {
        log.debug("Unmapped attribute: " + field.getName() + " [" + ex.toString() + "]");
    }
}