is there any reason as to why `Job` doesn't have a...
# coroutines
m
is there any reason as to why
Job
doesn't have a Failed state like
Deferred
? currently a Job that fails (e.g throws an unhandled exception) ends up in a Completed state. The only way to actually know if it was a failure is by checking the message of the
CancellationException
. Here is an example:
Copy code
fun main(args: Array<String>) = runBlocking {
    val job = launch {
        throw TODO("Not ready!")
    }

    // wait for it to crash
    delay(200)

    println("cancelled [${job.isCancelled}]")   // -> false
    println("active [${job.isActive}]")         // -> false
    println("completed [${job.isCompleted}]")   // -> true
}
☝️ 1