Can you not do any exception handling in coroutine...
# coroutines
r
Can you not do any exception handling in coroutines? I have this:
Copy code
launch { field.setAs { calculate() } }
...
private fun StringProperty.setAs(calc: () -> Any) = set(
    try {
        calc().toString()
    } catch (e: Exception) {
        e.message
    }
)
(Note that
setAs
has no suspension at all)
But if
calc
throws an exception, it isn't caught and instead just crashes. Am I missing something obvious?
s
What if you catch a
Throwable
instead of an
Exception
?
👍 1
r
Ah, that works. Apparently it was an
Error
being thrown, not an
Exception
. Thanks!