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:net.sf.firemox.xml.XmlModifier.java

/**
 * <ul>/*w ww  .  ja  v a2 s.c o  m*/
 * Structure of InputStream : Data[size]
 * <li>modifier name [String]</li>
 * <li>live update [boolean]</li>
 * <li>linked to creator [boolean]</li>
 * <li>activationZone [IdZone]</li>
 * <li>activated while this condition [Test]</li>
 * <li>exists until this triggered event [Event[]]</li>
 * <li>layer [integer]</li>
 * </ul>
 * 
 * @param node
 *          the XML card structure
 * @param out
 *          output stream where the card structure will be saved
 */
public static void buildMdbModifier(Node node, OutputStream out) {
    // write the name
    try {
        MToolKit.writeString(out, node.getAttribute("name"));

        // write the "live-update" attribute
        out.write("false".equals(node.getAttribute("live-update")) ? 0 : 1);

        final String activationZone = node.getAttribute("activation-zone");
        if (StringUtils.isBlank(activationZone)) {
            out.write(IdZones.PLAY);
        } else {
            out.write(XmlTools.getZone(activationZone));
        }

        // write the while condition
        final boolean oldValue = XmlTools.defaultOnMeTag;
        XmlTools.defaultOnMeTag = false;
        XmlTest.getTest("test").buildMdb(node.get("while"), out);
        XmlTools.defaultOnMeTag = oldValue;

        // creator link
        String linked = node.getAttribute("linked");
        out.write(linked != null && "true".equals(linked) ? 1 : 0);

        // write the until events
        Node until = node.get("until");
        if (until == null) {
            // permanent attachment (until attached object remove this modifier)
            out.write(0);
        } else {
            until.addAttribute(new XmlParser.Attribute("zone", "play"));
            out.write(until.getNbNodes());
            for (java.lang.Object obj : until) {
                if (obj instanceof Node) {
                    Node child = (Node) obj;
                    if ("text".equals(child.getTag())) {
                        XmlConfiguration
                                .warning("text element in 'until condition' of modifier is not yet implement");
                    } else {
                        XmlEvent.getEvent(child.getTag()).buildMdb(child, out);
                        break;
                    }
                }
            }
        }

        // write the modifier positioning strategy (layer)
        Layer.valueOfXsd(node.getAttribute("layer")).serialize(out);
    } catch (Throwable e2) {
        XmlConfiguration.error(
                "Error found in modifier '" + node.getTag() + "' : " + e2.getMessage() + ". Context=" + node);
    }
}

From source file:io.cloudslang.content.utils.OutputUtilities.java

/**
 * Creates a Map<String, String> with the RETURN_CODE Failure(-1), RETURN_RESULT the <throwable> message and with EXCEPTION the full stackTrace of the <throwable>
 *
 * @param throwable Exception with the message for the RETURN_RESULT and the fullStackTrace for the EXCEPTION of the map
 * @return a Map<String, String> with the RETURN_CODE Failure(-1), RETURN_RESULT the <throwable> message and with EXCEPTION the full stackTrace of the <throwable>
 *///from  w  w w .j a  va2  s  . c  o m
@NotNull
public static Map<String, String> getFailureResultsMap(@NotNull final Throwable throwable) {
    final Map<String, String> results = new HashMap<>();
    results.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE);
    results.put(OutputNames.RETURN_RESULT, throwable.getMessage());
    results.put(OutputNames.EXCEPTION, ExceptionUtils.getStackTrace(throwable));
    return results;
}

From source file:net.rim.ejde.internal.util.WorkspaceDependencyUtils.java

static public void addUserLibraryToProject(String userLibrary, IJavaProject iJavaProject,
        IProgressMonitor monitor) {/* w  w w. java  2s. c o m*/
    UserLibrary library = JavaModelManager.getUserLibraryManager().getUserLibrary(userLibrary);

    if (null != library && null != iJavaProject) {
        UserLibraryClasspathContainer container = new UserLibraryClasspathContainer(userLibrary);

        IPath path = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(userLibrary);

        try {
            JavaCore.setClasspathContainer(path, new IJavaProject[] { iJavaProject },
                    new IClasspathContainer[] { container },
                    null == monitor ? new NullProgressMonitor()
                            : monitor instanceof SubProgressMonitor ? monitor
                                    : new SubProgressMonitor(monitor, 1));
        } catch (Throwable e) {
            _log.error(e.getMessage(), e);
        } finally {
            monitor.done();
        }
    }
}

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

public static long getAvailableSpace(File dir) {
    try {//  ww  w . j a  va  2  s. com
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
        return -1;
    }

}

From source file:com.ddiiyy.xydz.xutils.util.OtherUtils.java

@SuppressWarnings("deprecation")
public static long getAvailableSpace(File dir) {
    try {//from  w ww  .j av a  2s .  c o m
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
        return -1;
    }

}

From source file:net.rim.ejde.internal.util.WorkspaceDependencyUtils.java

static public void addUserLibraryToProjects(String userLibrary, IJavaProject[] iJavaProjects,
        IProgressMonitor monitor) {//from w  ww.  ja  va 2s  .  co m
    UserLibrary library = JavaModelManager.getUserLibraryManager().getUserLibrary(userLibrary);

    if (null != library && null != iJavaProjects && 0 < iJavaProjects.length) {
        UserLibraryClasspathContainer[] containers = new UserLibraryClasspathContainer[iJavaProjects.length];

        IPath path;

        path = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append(userLibrary);

        for (int i = 0; i < iJavaProjects.length; i++)
            containers[i] = new UserLibraryClasspathContainer(userLibrary);

        try {
            JavaCore.setClasspathContainer(path, iJavaProjects, containers, null == monitor
                    ? new NullProgressMonitor()
                    : monitor instanceof SubProgressMonitor ? monitor : new SubProgressMonitor(monitor, 1));
        } catch (Throwable e) {
            _log.error(e.getMessage(), e);
        } finally {
            monitor.done();
        }
    }
}

From source file:com.scsy150.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/*www. ja  v a  2 s .  co  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) {
            LogUtil.e("", e.getMessage());
        }
    }

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

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

public static long getAvailableSpace(File dir) {
    try {/*from w  w  w.  j  av a2 s .c  o m*/
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        TatansLogUtils.e(e.getMessage(), e);
        return -1;
    }

}

From source file:com.googlecode.dex2jar.test.V3Test.java

public static void doData(byte[] data, final File destDir) throws IOException {

    final int lineCount = 50;

    DexFileReader reader = new DexFileReader(data);
    V3InnerClzGather afa = new V3InnerClzGather();
    final List<String> exes = new ArrayList<String>();
    reader.accept(afa, DexFileReader.SKIP_CODE | DexFileReader.SKIP_DEBUG);
    System.out.flush();//from  w ww .j  a v  a  2  s. c om
    String logFileName = "target/v3.log." + System.currentTimeMillis();
    final PrintWriter log = new PrintWriter(logFileName, "UTF-8");
    System.out.write(String.format("%05d ", 0).getBytes(UTF8));
    reader.accept(new V3(afa.getClasses(), null, new ClassVisitorFactory() {
        int count = 0;

        @Override
        public ClassVisitor create(final String name) {
            return new ClassWriter(ClassWriter.COMPUTE_MAXS) {
                @Override
                public void visitEnd() {
                    count++;
                    try {
                        super.visitEnd();
                        byte[] data = this.toByteArray();
                        FileUtils.writeByteArrayToFile(new File(destDir, name + ".class"), data);
                        TestUtils.verify(new ClassReader(data), log);
                        System.out.write('.');
                    } catch (Throwable e) {
                        System.out.write('X');
                        exes.add(String.format("%05d %s - %s", count - 1, name, e.getMessage()));
                    }
                    if (count % lineCount == 0) {
                        try {
                            System.out.write(String.format("\n%05d ", count).getBytes(UTF8));
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    System.out.flush();
                }
            };
        }
    }, V3.REUSE_REGISTER | V3.TOPOLOGICAL_SORT | V3.OPTIMIZE_SYNCHRONIZED), DexFileReader.SKIP_DEBUG);
    System.out.flush();
    System.out.println();
    log.close();
    if (exes.size() > 0) {
        StringBuilder sb = new StringBuilder("there are ").append(exes.size())
                .append(" error(s) while translate\n");
        for (String ln : exes) {
            sb.append(ln).append("\n");
        }
        sb.append("details: ").append(logFileName).append("\n");
        throw new RuntimeException(sb.toString());
    }
}

From source file:br.eti.kinoshita.selenium.util.Utils.java

/**
 * Wait for assync content in a determined period
 * /*ww  w.  ja va 2  s.co m*/
 * @param driver Selenium web driver.
 * @param by Selenium By expression.
 * @param timeout Selenium time out.
 * @return a WebElement asynchronously loaded.
 * @throws NoSuchElementException
 */
public static WebElement waitForAssyncContent(WebDriver driver, By by, Long timeout)
        throws NoSuchElementException {
    long end = System.currentTimeMillis() + (timeout);
    WebElement renderedWebElement = null;

    while (System.currentTimeMillis() < end) {
        try {
            renderedWebElement = driver.findElement(by);
        } catch (NoSuchElementException nsee) {
            LOGGER.debug(nsee.getMessage(), nsee);
        }

        if (renderedWebElement != null && renderedWebElement.isEnabled() && renderedWebElement.isDisplayed()) {
            return renderedWebElement;
        }

        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            LOGGER.debug(ie.getMessage(), ie);
        }
    }

    if (renderedWebElement == null) {
        throw new NoSuchElementException("Could not locate assync content");
    }

    try {
        if (renderedWebElement.isDisplayed()) {
            throw new NoSuchElementException("Element is not being displayed");
        }
    } catch (Throwable t) {
        LOGGER.debug(t.getMessage(), t);
    }

    return renderedWebElement;
}