当前位置: 首页>>代码示例>>Java>>正文


Java Exceptions.unwrap方法代码示例

本文整理汇总了Java中org.seamless.util.Exceptions.unwrap方法的典型用法代码示例。如果您正苦于以下问题:Java Exceptions.unwrap方法的具体用法?Java Exceptions.unwrap怎么用?Java Exceptions.unwrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.seamless.util.Exceptions的用法示例。


在下文中一共展示了Exceptions.unwrap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterExecute

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
@Override
protected void afterExecute(Runnable runnable, Throwable throwable) {
    super.afterExecute(runnable, throwable);
    if (throwable != null) {
        Throwable cause = Exceptions.unwrap(throwable);
        if (cause instanceof InterruptedException) {
            // Ignore this, might happen when we shutdownNow() the executor. We can't
            // log at this point as the logging system might be stopped already (e.g.
            // if it's a CDI component).
            return;
        }
        // Log only
        log.warning("Thread terminated " + runnable + " abruptly with exception: " + throwable);
        log.warning("Root cause: " + cause);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:17,代码来源:DefaultUpnpServiceConfiguration.java

示例2: run

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
public void run() {
    try {
        execute();
    } catch (Exception ex) {
        Throwable cause = Exceptions.unwrap(ex);
        if (cause instanceof InterruptedException) {
            log.log(Level.INFO, "Interrupted protocol '" + getClass().getSimpleName() + "': " + ex, cause);
        } else {
            throw new RuntimeException(
                "Fatal error while executing protocol '" + getClass().getSimpleName() + "': " + ex, ex
            );
        }
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:15,代码来源:SendingAsync.java

示例3: handleRouterExceptionOnNetworkTypeChange

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex) {
    Throwable cause = Exceptions.unwrap(ex);
    if (cause instanceof InterruptedException) {
        log.log(Level.INFO, "Router was interrupted: " + ex, cause);
    } else {
        throw new RuntimeException("Router error on network change: " + ex, ex);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:9,代码来源:AndroidRouter.java

示例4: shutdownRouter

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
protected void shutdownRouter() {
    try {
        getRouter().shutdown();
    } catch (RouterException ex) {
        Throwable cause = Exceptions.unwrap(ex);
        if (cause instanceof InterruptedException) {
            log.log(Level.INFO, "Router shutdown was interrupted: " + ex, cause);
        } else {
            throw new RuntimeException("Router error on shutdown: " + ex, ex);
        }
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:13,代码来源:UpnpServiceImpl.java

示例5: writeFile

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
protected void writeFile(Activity activity, File file, String xml) {
    try {
        log.info("Writing OPML XML to file: " + file);
        IO.writeUTF8(file, xml);
    } catch (Exception ex) {
        Throwable cause = Exceptions.unwrap(ex);
        log.log(Level.WARNING, "Error writing OPML XML file: " + file, cause);
        Toast.makeText(activity, "Error writing OPML XML file, check the log: " + file, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:4thline,项目名称:feeds,代码行数:11,代码来源:Exporter.java

示例6: exportOPML

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
public void exportOPML(final Activity activity, Uri fileUri) {
    Toast.makeText(activity, "Exporting feeds to OPML file...", Toast.LENGTH_SHORT).show();

    final File file = new File(fileUri.getPath(), OPML.DEFAULT_FILENAME);

    try {
        List<OPML.Outline> outlines = new ArrayList<OPML.Outline>();
        Cursor c = null;
        try {
            log.fine("Loading feed configs");
            c = activity.getContentResolver().query(FeedConfig.CONTENT_URI, null, null, null, null);
            while (c.moveToNext()) {
                OPML.Outline outline = new OPML.Outline(c);
                outlines.add(outline);
            }
        } finally {
            if (c != null) c.close();
        }

        log.fine("Generating XML for feed configs: " + outlines.size());

        OPMLParser parser = new OPMLParser();
        final String result = parser.write(outlines);

        if (file.exists()) {
            log.fine("File exists, confirming overwrite: " + file);
            new AlertDialog.Builder(activity)
                .setTitle("Overwrite file?")
                .setMessage("OMPL export file exists in this directory, are you sure you want to overwrite it?")
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        writeFile(activity, file, result);
                    }
                })
                .setNegativeButton(android.R.string.no, null)
                .show();
        } else {
            log.fine("File doesn't exist, creating: " + file);
            file.createNewFile();
            writeFile(activity, file, result);
        }

    } catch (Exception ex) {
        Throwable cause = Exceptions.unwrap(ex);
        log.log(Level.WARNING, "Error writing OPML XML file: " + file, cause);
        Toast.makeText(activity, "Error writing OPML XML file, check the log: " + file, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:4thline,项目名称:feeds,代码行数:50,代码来源:Exporter.java

示例7: importOPML

import org.seamless.util.Exceptions; //导入方法依赖的package包/类
public boolean importOPML(Activity activity, Uri fileUri) {
    Toast.makeText(activity, "Importing feeds from OPML file...", Toast.LENGTH_SHORT).show();
    File file = new File(fileUri.getPath());

    try {
        log.info("Reading OPML XML file: " + file);
        String opml = IO.readLines(file);

        OPMLParser parser = new OPMLParser();
        List<OPML.Outline> result = parser.read(opml);

        log.info("Importing feeds: " + result.size());
        int newFeeds = 0;
        for (OPML.Outline outline : result) {

            String feedURL = outline.xmlUrl;

            Cursor c = null;
            try {
                String encodedURL = URIUtil.encodePathSegment(feedURL);
                log.fine("Checking existing feed config: " + encodedURL);
                Uri uri = Uri.withAppendedPath(
                    FeedConfig.CONTENT_URI_BY_URL, encodedURL);
                c = activity.getContentResolver().query(uri, null, null, null, null);
                if (c.moveToFirst()) {
                    log.info("Feed with this URL exists, skipping: " + feedURL);
                    continue;
                }
            } finally {
                if (c != null) c.close();
            }

            log.info("Importing new feed: " + feedURL);
            newFeeds++;
            FeedConfig feedConfig = outline.toFeedConfig();
            activity.getContentResolver().insert(
                FeedConfig.CONTENT_URI, feedConfig.INSTANCE.getEntityValues()
            );
        }

        return newFeeds > 0;

    } catch (Exception ex) {
        Throwable cause = Exceptions.unwrap(ex);
        log.log(Level.WARNING, "Error importing OPML XML file: " + file, cause);
        Toast.makeText(activity, "Error importing OPML XML file, check the log: " + file, Toast.LENGTH_LONG).show();
    }
    return false;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:50,代码来源:Importer.java


注:本文中的org.seamless.util.Exceptions.unwrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。