ahorn / android-rss

Lightweight Android library to parse RSS 2.0 feeds.
529 stars 176 forks source link

FATAL EXCEPTION: AsyncTask #1 when no internet. #28

Closed ashleypeacock closed 8 years ago

ashleypeacock commented 8 years ago

Unfortunately not much more information is given although it is caused by this line:

feed = reader.load(uri);

ahorn commented 8 years ago

If you think this is a bug, could you reproduce this exception with a test case? See https://github.com/ahorn/android-rss/tree/master/src/test/java/org/mcsoxford/rss

What behaviour would you expect?

ashleypeacock commented 8 years ago

Yep sure thing. I am pretty sure this is a bug i've tried multiple ways around this. Just trying to get the sources imported into Android studio. Thanks for your reply :)

ashleypeacock commented 8 years ago

Ok, So load(url) was throwing an RSSFault which I wasn't catching as I was only catching RSSExceptions. Added this which prevents the problem with ASyncTask.

protected RSSFeed doInBackground(String... urls) {
            RSSReader reader = new RSSReader();
            RSSFeed feed = null;
            try {
                feed = reader.load(urls[0]);
                feed.toString();
            }catch(RSSException rs) {
                Log.e(this.getClass().getSimpleName(), "Error gettig list", rs);
            } catch (RSSFault fault) {
                Log.e(this.getClass().getSimpleName(), "Error with RSSFault", fault);
            }
            return feed;
        }
ahorn commented 8 years ago

It would make sense if fault.getCause() and fault.getMessage() indicate that an IOException was raised (should you wish to make your error message more precise).