Skip to content

Commit

Permalink
Draft for discussion: on sending a signal when networking fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jingwei99 committed Jan 10, 2024
1 parent f1a2f74 commit 14e1d91
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.modules.EmptySerializersModule
import kotlinx.serialization.modules.SerializersModule
import okio.FileSystem
import okio.IOException
import okio.Path

/**
Expand Down Expand Up @@ -182,7 +183,10 @@ class ZiplineLoader internal constructor(
}
manifestUrlFlow.collect { manifestUrl ->
if (previousManifest != null &&
freshnessChecker.isFresh(previousManifest!!, previousManifest!!.freshAtEpochMs ?: Long.MIN_VALUE)
freshnessChecker.isFresh(
previousManifest!!,
previousManifest!!.freshAtEpochMs ?: Long.MIN_VALUE
)
) {
return@collect
} else {
Expand Down Expand Up @@ -281,6 +285,9 @@ class ZiplineLoader internal constructor(
// If emit() threw a CancellationException, consider that emit to be successful.
// That's 'cause loadOnce() accepts an element and then immediately cancels the flow.
throw e
} catch (e: IOException) {
send(LoadResult.Failure(e))
return null
} catch (e: Exception) {
eventListener.applicationLoadFailed(applicationName, manifestUrl, e, startValue)
if (loadedManifest != null) {
Expand Down

0 comments on commit 14e1d91

Please sign in to comment.