Skip to content

Commit 62ada11

Browse files
authored
Merge pull request #222 from blacklight/214/handle-feed-exceptions-during-sync
[#214] Handle feed exceptions during sync.
2 parents 0573986 + 495eec9 commit 62ada11

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

app/src/main/kotlin/api/miniflux/MinifluxApiAdapter.kt

+29-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package api.miniflux
22

3+
import android.util.Log
34
import api.Api
45
import co.appreactor.feedk.AtomLinkRel
56
import db.Entry
@@ -39,7 +40,16 @@ class MinifluxApiAdapter(
3940
}
4041

4142
override suspend fun getFeeds(): Result<List<Feed>> {
42-
return runCatching { api.getFeeds().mapNotNull { it.toFeed() } }
43+
return runCatching {
44+
api.getFeeds().mapNotNull {
45+
try {
46+
it.toFeed()
47+
} catch (e: Exception) {
48+
Log.w("MinifluxApiAdapter", "Failed to parse feed ${it.feed_url}", e)
49+
null
50+
}
51+
}
52+
}
4353
}
4454

4555
override suspend fun updateFeedTitle(feedId: String, newTitle: String): Result<Unit> {
@@ -143,22 +153,27 @@ class MinifluxApiAdapter(
143153
extCacheUri = null,
144154
)
145155

146-
val alternateLink = Link(
147-
feedId = feedId,
148-
entryId = null,
149-
href = site_url.toHttpUrl(),
150-
rel = AtomLinkRel.Alternate,
151-
type = "text/html",
152-
hreflang = null,
153-
title = null,
154-
length = null,
155-
extEnclosureDownloadProgress = null,
156-
extCacheUri = null,
157-
)
156+
val alternateLink = try {
157+
Link(
158+
feedId = feedId,
159+
entryId = null,
160+
href = site_url.toHttpUrl(),
161+
rel = AtomLinkRel.Alternate,
162+
type = "text/html",
163+
hreflang = null,
164+
title = null,
165+
length = null,
166+
extEnclosureDownloadProgress = null,
167+
extCacheUri = null,
168+
)
169+
} catch (e: Exception) {
170+
Log.d("MinifluxApiAdapter", "Failed to parse alternate link for feed $feed_url", e)
171+
null
172+
}
158173

159174
return Feed(
160175
id = feedId,
161-
links = listOf(selfLink, alternateLink),
176+
links = listOfNotNull(selfLink, alternateLink),
162177
title = title,
163178
ext_open_entries_in_browser = false,
164179
ext_blocked_words = "",

0 commit comments

Comments
 (0)