prof18 / RSS-Parser

A Kotlin Multiplatform library to parse a RSS Feed
Apache License 2.0
490 stars 126 forks source link

Fatal Exception: com.prof18.rssparser.exception.HttpException #119

Closed saldous closed 10 months ago

saldous commented 10 months ago

Updated my app from v5.0.3 to 6.0.1 and suddenly getting this from some user logs:

Fatal Exception: com.prof18.rssparser.exception.HttpException:
       at com.prof18.rssparser.internal.JvmXmlFetcher$await$2$2.onResponse(JvmXmlFetcher.kt:48)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)

I've not been able to reproduce it yet, but over 100 crash events reported in Crashlytics

prof18 commented 10 months ago

Hi, that's an expected behaviour. This exception happens if the URL returns an HTTP error not in the range from 200 to 299. The logic didn't change with the new release

saldous commented 10 months ago

@prof18 how can I catch it so it doesn't crash the app? I'm already doing:

try {
    val channel = parser.getRssChannel(feed.url)
} catch (e: Exception) {
    println(e.message)
}

yet the app is crashing

prof18 commented 10 months ago

You can catch it with HttpException or Throwable!

But, I realized that HttpException extends Throwable and not Exception, that's because your try/catch didn't catch the exception. I will release a bugfix ASAP.

Thanks for reporting!

TwinklingToon commented 10 months ago

i want to fetch details in rss having following tag

how this can be done?

prof18 commented 10 months ago

@TwinklingToon can you please open a new issue and provide a link to the RSS feed?