-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent some crashes to happen on desktop
- Loading branch information
Showing
5 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
shared/src/commonJvmAndroidMain/kotlin/com/prof18/feedflow/domain/JvmHtmlRetriever.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package com.prof18.feedflow.domain | ||
|
||
import co.touchlab.kermit.Logger | ||
import com.prof18.feedflow.utils.DispatcherProvider | ||
import kotlinx.coroutines.withContext | ||
import org.jsoup.Jsoup | ||
|
||
internal class JvmHtmlRetriever( | ||
private val dispatcherProvider: DispatcherProvider, | ||
private val logger: Logger, | ||
) : HtmlRetriever { | ||
override suspend fun retrieveHtml(url: String): String? = withContext(dispatcherProvider.io) { | ||
return@withContext Jsoup.connect(url).get().html() | ||
try { | ||
return@withContext Jsoup.connect(url).get().html() | ||
} catch (e: Exception) { | ||
logger.e(e) { "Unable to retrieve HTML, skipping" } | ||
return@withContext null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters