File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
app/src/main/java/org/schabi/newpipe/paging Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,20 @@ class CommentRepliesSource(
1515 private val service = NewPipe .getService(commentInfo.serviceId)
1616
1717 override suspend fun load (params : LoadParams <Page >): LoadResult <Page , CommentsInfoItem > {
18- // params.key is null the first time load() is called, and we need to return the first page
19- val repliesPage = params.key ? : commentInfo.replies
20- val info = withContext(Dispatchers .IO ) {
21- CommentsInfo .getMoreItems(service, commentInfo.url, repliesPage)
18+ return try {
19+ // params.key is null the first time load() is called, and we need to return the first page
20+ val repliesPage = params.key ? : commentInfo.replies
21+
22+ val info = withContext(Dispatchers .IO ) {
23+ CommentsInfo .getMoreItems(service, commentInfo.url, repliesPage)
24+ }
25+
26+ LoadResult .Page (info.items, null , info.nextPage)
27+ } catch (e: Exception ) {
28+ // Catches UnknownHostException (offline) or any extraction errors
29+ // and tells Paging3 to show the error state in the UI.
30+ LoadResult .Error (e)
2231 }
23- return LoadResult .Page (info.items, null , info.nextPage)
2432 }
2533
2634 override fun getRefreshKey (state : PagingState <Page , CommentsInfoItem >) = null
You can’t perform that action at this time.
0 commit comments