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:eu.wordnice.wnconsole.WNCUtils.java

protected static Thread createHIOThread(final HIOServer serv, final Handler.TwoVoidHandler<Thread, HIO> handl,
        final boolean debug, final long timeout, final Logger lg) {
    return new Thread() {
        @Override/*from  w  w  w  .ja v  a 2s  .  c  om*/
        public void run() {
            serv.onAcceptRaw(new Handler.OneVoidHandler<Socket>() {
                @Override
                public void handle(Socket sock) {
                    try {
                        final HIO hio = new HIO(sock);
                        Thread rt = new Thread() {
                            @Override
                            public void run() {
                                try {
                                    hio.decode(false, timeout);
                                    handl.handle(this, hio);
                                } catch (Throwable th) {
                                    if (debug) {
                                        lg.info("Error while accepting client from "
                                                + hio.sock.getInetAddress().toString() + ", path [" + hio.PATH
                                                + "], error " + th.getMessage());
                                    }
                                }
                                try {
                                    hio.close();
                                } catch (Throwable tign) {
                                }
                            }
                        };
                        tid++;
                        rt.setName("WNC HIO Handle " + tid);
                        rt.start();
                    } catch (Throwable t) {
                    }
                }
            });
        }
    };
}

From source file:com.sshtools.appframework.api.ui.SshToolsApplicationPanel.java

protected static void appendException(Throwable exception, int level, StringBuffer buf, boolean details) {
    try {//from   w w w  . j  a  v a2 s .  co m
        if (((exception != null) && (exception.getMessage() != null))
                && (exception.getMessage().length() > 0)) {
            if (details && (level > 0)) {
                buf.append("\n \nCaused by ...\n");
            }
            buf.append(exception.getMessage());
        }
        if (details) {
            if (exception != null) {
                if ((exception.getMessage() != null) && (exception.getMessage().length() == 0)) {
                    buf.append("\n \nCaused by ...");
                } else {
                    buf.append("\n \n");
                }
            }
            StringWriter sw = new StringWriter();
            if (exception != null) {
                exception.printStackTrace(new PrintWriter(sw));
            }
            buf.append(sw.toString());
        }
        try {
            java.lang.reflect.Method method = exception.getClass().getMethod("getCause", new Class[] {});
            Throwable cause = (Throwable) method.invoke((Object) exception, (Object[]) null);
            if (cause != null) {
                appendException(cause, level + 1, buf, details);
            }
        } catch (Exception e) {
        }
    } catch (Throwable ex) {
    }
}

From source file:net.sf.jabref.exporter.FileActions.java

/**
 * Saves the database to file, including only the entries included in the
 * supplied input array bes./*from   w w w  . j  a  v a 2s  . com*/
 *
 * @return A List containing warnings, if any.
 */
public static SaveSession savePartOfDatabase(BibDatabase database, MetaData metaData, File file,
        JabRefPreferences prefs, BibEntry[] bes, Charset encoding, DatabaseSaveType saveType)
        throws SaveException {

    BibEntry be = null;
    boolean backup = prefs.getBoolean(JabRefPreferences.BACKUP);

    SaveSession session;
    try {
        session = new SaveSession(file, encoding, backup);
    } catch (IOException e) {
        throw new SaveException(e.getMessage(), e.getLocalizedMessage());
    }

    // Map to collect entry type definitions
    // that we must save along with entries using them.
    Map<String, EntryType> types = new TreeMap<>();

    // Define our data stream.
    try (VerifyingWriter fw = session.getWriter()) {

        if (saveType != DatabaseSaveType.PLAIN_BIBTEX) {
            // Write signature.
            FileActions.writeBibFileHeader(fw, encoding);
        }

        // Write preamble if there is one.
        FileActions.writePreamble(fw, database.getPreamble());

        // Write strings if there are any.
        FileActions.writeStrings(fw, database);

        // Write database entries. Take care, using CrossRefEntry-
        // Comparator, that referred entries occur after referring
        // ones. Apart from crossref requirements, entries will be
        // sorted as they appear on the screen.
        List<Comparator<BibEntry>> comparators = FileActions.getSaveComparators(true, metaData);

        // Use glazed lists to get a sorted view of the entries:
        List<BibEntry> sorter = new ArrayList<>(bes.length);
        Collections.addAll(sorter, bes);
        Collections.sort(sorter, new FieldComparatorStack<>(comparators));

        BibEntryWriter bibtexEntryWriter = new BibEntryWriter(new LatexFieldFormatter(), true);

        for (BibEntry aSorter : sorter) {
            be = aSorter;

            // Check if we must write the type definition for this
            // entry, as well. Our criterion is that all non-standard
            // types (*not* customized standard types) must be written.
            EntryType tp = be.getType();
            if (EntryTypes.getStandardType(tp.getName()) == null) {
                types.put(tp.getName(), tp);
            }

            bibtexEntryWriter.write(be, fw);
            //only append newline if the entry has changed
            if (!be.hasChanged()) {
                fw.write(Globals.NEWLINE);
            }
        }

        // Write meta data.
        if ((saveType != DatabaseSaveType.PLAIN_BIBTEX) && (metaData != null)) {
            metaData.writeMetaData(fw);
        }

        // Write type definitions, if any:
        if (!types.isEmpty()) {
            for (Map.Entry<String, EntryType> stringBibtexEntryTypeEntry : types.entrySet()) {
                CustomEntryType tp = (CustomEntryType) stringBibtexEntryTypeEntry.getValue();
                CustomEntryTypesManager.save(tp, fw);
                fw.write(Globals.NEWLINE);
            }

        }
    } catch (Throwable ex) {
        session.cancel();
        //repairAfterError(file, backup, status);
        throw new SaveException(ex.getMessage(), ex.getLocalizedMessage(), be);
    }

    return session;

}

From source file:com.github.nukesparrow.htmlunit.DebuggingWebConnection.java

protected static Map boxThrowable(Throwable ex) {
    Map m = new LinkedHashMap();
    m.put("time", System.currentTimeMillis());
    m.put("message", ex.getMessage());
    m.put("class", ex.getClass().getCanonicalName());
    StringWriter sw = new StringWriter();
    ex.printStackTrace(new PrintWriter(sw, true));
    m.put("stack", sw.toString());
    return m;//from  w  w  w. j  a v  a 2s .c om
}

From source file:fiftyfive.wicket.util.LoggingUtils.java

/**
 * Writes to the logger a best-guess at the most concise description of
 * the exception by first unwrapping it (see {@link #unwrap upwrap}), then
 * writes a large amount of information regarding the current Wicket state
 * (see {@link #dumpWicketState dumpWicketState}), and finally writes the
 * full stack traces of the entire exception chain.
 * <p>/*from ww  w  . j  a v a  2s  .c om*/
 * Example logger output:
 * <pre class="example">
 * ParseException: Unparseable date: "1xxx07"
 *
 * Request:
 *   URL       = wicket/bookmarkable/fiftyfive.wicket.examples.formtest.FormTestPage?0&initialMonth=10.2007&startDate=1xxx07&endDate=11.10.2007
 *   Handler   = RenderPageRequestHandler
 *   Component = FormTestPage
 *   Duration  = 485 milliseconds
 * Session:
 *   ID       = 1sxy938y7qoqq942z4pnuqdqt
 *   Info     = TODO: Your session info goes here
 *   Size     = 716 bytes
 *   Duration = 310 milliseconds
 * Application:
 *   Active Sessions = 1 (1 peak)
 *   Memory Usage    = 25M used, 40M free, 533M max
 *   IP Address      = 172.16.1.14
 *   Uptime          = 10.9 seconds
 * Headers:
 *   Host            = localhost:8080
 *   User-Agent      = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
 *   Accept          = application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,&#042;/&#042;;q=0.5
 *   Cache-Control   = max-age=0
 *   Accept-Language = en-us
 *   Accept-Encoding = gzip, deflate
 *   Cookie          = JSESSIONID=1217fv4qjpnbnv1ewzzmonevh
 *   Connection      = keep-alive
 * 
 * Message: Error calling method: public java.util.Date fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate() on object: [ [Component id = calendar-control]]
 * 
 * Root cause:
 * 
 * java.text.ParseException: Unparseable date: "1xxx07"
 *      at java.text.DateFormat.parse(DateFormat.java:337)
 *      at fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate(FormTestPage.java:82)
 *      at java.lang.reflect.Method.invoke(Method.java:597)
 *      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1112)
 *      at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637)
 *      at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96)
 *      at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122)
 *      at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168)
 *      at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260)
 *      at org.apache.wicket.Component.renderHead(Component.java:2627)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193)
 *      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64)
 *      at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125)
 *      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140)
 *      at org.apache.wicket.Component.renderComponent(Component.java:2518)
 *      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466)
 *      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589)
 *      at org.apache.wicket.Page.onRender(Page.java:1139)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.Page.renderPage(Page.java:1289)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199)
 *      at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149)
 *      at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248)
 *      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131)
 *      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:184)
 *      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 *      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
 *      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 *      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 *      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 *      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 *      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 *      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 *      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
 *      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 *      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 *      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 *      at org.mortbay.jetty.Server.handle(Server.java:326)
 *      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 *      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
 *      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
 *      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 *      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 *      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 *      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
 * 
 * 
 * Complete stack:
 * 
 * org.apache.wicket.WicketRuntimeException: Error calling method: public java.util.Date fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate() on object: [ [Component id = calendar-control]]
 *      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1116)
 *      at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637)
 *      at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96)
 *      at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122)
 *      at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168)
 *      at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260)
 *      at org.apache.wicket.Component.renderHead(Component.java:2627)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193)
 *      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64)
 *      at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125)
 *      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140)
 *      at org.apache.wicket.Component.renderComponent(Component.java:2518)
 *      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466)
 *      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589)
 *      at org.apache.wicket.Page.onRender(Page.java:1139)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.Page.renderPage(Page.java:1289)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199)
 *      at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149)
 *      at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248)
 *      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131)
 * 
 * java.lang.RuntimeException: java.text.ParseException: Unparseable date: "1xxx07"
 *      at fiftyfive.wicket.examples.formtest.FormTestPage$1.getStartDate(FormTestPage.java:87)
 *      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 *      at java.lang.reflect.Method.invoke(Method.java:597)
 *      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1112)
 *      at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:637)
 *      at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:96)
 *      at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:122)
 *      at fiftyfive.wicket.datetime.RestrictedDatePicker.configure(RestrictedDatePicker.java:168)
 *      at org.apache.wicket.extensions.yui.calendar.DatePicker.renderHead(DatePicker.java:260)
 *      at org.apache.wicket.Component.renderHead(Component.java:2627)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:70)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy$1.component(ParentFirstHeaderRenderStrategy.java:66)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:161)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:117)
 *      at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:193)
 *      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:941)
 *      at org.apache.wicket.markup.renderStrategy.ParentFirstHeaderRenderStrategy.renderChildHeaders(ParentFirstHeaderRenderStrategy.java:64)
 *      at org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy.renderHeader(AbstractHeaderRenderStrategy.java:125)
 *      at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:140)
 *      at org.apache.wicket.Component.renderComponent(Component.java:2518)
 *      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1527)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1466)
 *      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1589)
 *      at org.apache.wicket.Page.onRender(Page.java:1139)
 *      at org.apache.wicket.Component.render_(Component.java:2380)
 *      at org.apache.wicket.Component.render(Component.java:2307)
 *      at org.apache.wicket.Page.renderPage(Page.java:1289)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131)
 *      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:199)
 *      at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:149)
 *      at org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:206)
 *      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:248)
 *      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:131)</pre>
 */
public static void logException(Logger logger, Exception e) {
    Args.notNull(logger, "logger");
    Args.notNull(e, "e");

    try {
        Throwable unwrapped = unwrap(e);

        logger.error(String.format("%s: %s%n%n%s%n%n%s", Classes.simpleName(unwrapped.getClass()),
                unwrapped.getMessage(), dumpWicketState(), Strings.toString(e)));
    } catch (Exception loggingEx) {
        // We should never arrive here, because it means that something
        // went terribly wrong in our logging code. Since our code failed,
        // fall back to simple logging so that Wicket error handling
        // can continue uninterrupted.
        LOGGER.error("Unexpected exception during logging", loggingEx);
        logger.error("RuntimeException", e);
    }
}

From source file:com.xqdev.sql.MLSQL.java

private static void addExceptions(Element meta, Throwable t) {
    if (t == null)
        return;//from w  ww .jav a 2  s.c  om

    Namespace sql = meta.getNamespace();
    Element exceptions = new Element("exceptions", sql);
    meta.addContent(exceptions);
    do {
        exceptions.addContent(new Element("exception", sql).setAttribute("type", t.getClass().getName())
                .addContent(new Element("reason", sql).setText(t.getMessage())));
        Log.log(t);
        t = t.getCause();
    } while (t != null);
}

From source file:edu.samplu.common.WebDriverUtil.java

public static void jGrowl(WebDriver driver, String jGrowlHeader, boolean sticky, String message, Throwable t) {
    if (jGrowlEnabled) { // check if jGrowl is enabled to skip over the stack trace extraction if it is not.
        jGrowl(driver, jGrowlHeader, sticky,
                message + " " + t.getMessage() + "\n" + ExceptionUtils.getStackTrace(t));
    }/*from   w w w .ja v a2  s .  c o m*/
}

From source file:com.oracle.tutorial.jdbc.JDBCTutorialUtilities.java

public static void printSQLException(SQLException ex) {
    for (Throwable e : ex) {
        if (e instanceof SQLException) {
            if (ignoreSQLException(((SQLException) e).getSQLState()) == false) {
                e.printStackTrace(System.err);
                System.err.println("SQLState: " + ((SQLException) e).getSQLState());
                System.err.println("Error Code: " + ((SQLException) e).getErrorCode());
                System.err.println("Message: " + e.getMessage());
                Throwable t = ex.getCause();
                while (t != null) {
                    System.out.println("Cause: " + t);
                    t = t.getCause();/*w  w w  .j  a va 2s  .co m*/
                }
            }
        }
    }
}

From source file:lucee.commons.io.res.type.s3.S3.java

private static String createSignature(String str, String secretAccessKey, String charset)
        throws InvalidKeyException, NoSuchAlgorithmException, IOException {
    //str=StringUtil.replace(str, "\\n", String.valueOf((char)10), false);
    byte[] digest = HMAC_SHA1(secretAccessKey, str, charset);
    try {//www. j  ava 2  s  .co  m
        return Caster.toB64(digest);
    } catch (Throwable t) {
        throw new IOException(t.getMessage());
    }
}

From source file:com.icesoft.faces.webapp.parser.JspPageToDocument.java

static String[] scanJar(JarURLConnection conn, String namespaceURL) throws IOException {
    JarFile jarFile = null;//from w w  w  .  ja va2  s .  c  o  m
    String resourcePath = conn.getJarFileURL().toString();

    if (log.isTraceEnabled()) {
        log.trace("Fallback Scanning Jar " + resourcePath);
    }

    jarFile = conn.getJarFile();
    Enumeration entries = jarFile.entries();
    while (entries.hasMoreElements()) {
        try {
            JarEntry entry = (JarEntry) entries.nextElement();
            String name = entry.getName();
            if (!name.startsWith("META-INF/")) {
                continue;
            }
            if (!name.endsWith(".tld")) {
                continue;
            }
            InputStream stream = jarFile.getInputStream(entry);
            try {
                String uri = getUriFromTld(resourcePath, stream);
                if ((uri != null) && (uri.equals(namespaceURL))) {
                    return (new String[] { resourcePath, name });
                }
            } catch (JasperException jpe) {
                if (log.isDebugEnabled()) {
                    log.debug(jpe.getMessage(), jpe);
                }
            } finally {
                if (stream != null) {
                    stream.close();
                }
            }
        } catch (Throwable t) {
            if (log.isDebugEnabled()) {
                log.debug(t.getMessage(), t);
            }
        }
    }

    return null;
}