Added RemoteSource.kt exception catch, dependencies update

This commit is contained in:
Arty Bishop committed 2021-11-09 11:48:29 +01:00
1 parent 5ba7ee746c
commit 04029d50db
4 files changed
+27 -20

No files matched your search

@@ -9,7 +9,11 @@ import java.net.URL
class RemoteSource(private val ioDispatcher: CoroutineDispatcher) : RemoteDataSource {
@Suppress("BlockingMethodInNonBlockingContext")
override suspend fun fetchFileStream(fileUrl: String): InputStream {
return withContext(ioDispatcher) { URL(fileUrl).openStream() }
override suspend fun fetchFileStream(url: String): InputStream? {
return try {
withContext(ioDispatcher) { URL(url).openStream() }
} catch (e: Exception) {
null
}
}
}