https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

Albert

03/29/2019, 2:46 PM
Is there a way with
SupervisorJob
to restart a coroutine when it stops exceptionally?
Copy code
supervisorScope {
  launch {
    throw Exception()
  }
}
r

r4zzz4k

03/29/2019, 3:06 PM
Like this, maybe?
Copy code
retry@ while(true) {
    try {
        throw Exception()
    } catch(e: Exception) {
        continue@retry
    }
    break@retry
}
3 Views