From my viewmodel I'm launching a coroutine that could fail and throw an exception, in my coroutine I'm explicitly doing this and instead of catching the exception my app crashes
ViewModel
viewModelScope.launch {
try {
repo.getData()
catch(e: Exception) { print(e) }
}
Repo
suspend fun getData(): Int {
val productId = getProductId()
if (productId == 0) throw Exception()
return productId
}
This crashes my app instead of handling the exception inside the viewmodelScope, I tought that any exception should be propagated to the caller and handled there