Can't getting Result.failure from suspend function

Hello. I started having problems after I upgraded the Kotlin version from 1.3.72 to 1.4.10.

I am used the function with coroutines return Result.success or failure by condition

But when an error occurs within this function, I can only catch it with try-catch. Before updating the version, I was capturing it in the else section in the image below.

I want to return data of Result type from the repository layer and do not use try-catch in the ViewModel.

Please help me.

You cant avoid try catch in coroutines as in async await in JS

Your code should work just fine. It might be that fetchUserStories is throwing an error outside of handleRequest, which is why it’s thrown as a regular error instead of a Result.Failure.