Benoît
01/25/2022, 10:44 AMintent
blocks has to throw an Exception to signify that the test has failed, I can see the Exception being passed to my CoroutineExceptionHandler
where I throw it, but the test somehow still passesMikolaj Leszczynski
01/25/2022, 10:51 AMMikolaj Leszczynski
01/25/2022, 10:51 AMBenoît
01/25/2022, 11:01 AMexceptionHandler
has been provided? Not necessarily talking about a test container here, more in generalMikolaj Leszczynski
01/25/2022, 11:01 AMBenoît
01/25/2022, 11:01 AMMikolaj Leszczynski
01/25/2022, 11:02 AMExceptionHandler
is given as an option - my personal preference is to handle exceptions locally in intents, and crash otherwise.miqbaldc
01/25/2022, 2:42 PMto handle exceptions locally in intentsdoes below is an equivalent snippet @Mikolaj Leszczynski mentioned(?)
fun doSomething() = intent {
runCatching { useCase/repo.doSomething() }
.onFailure {}
.onSuccess {}
}
Mikolaj Leszczynski
01/25/2022, 2:43 PMBenoît
01/25/2022, 6:00 PMEither
from arrow-kt
It's best to do that outside the business logic (here, the ContainerHost), so my repositories would return an Either<Error,Success>
instead of crashing.
If something crashes, then it means I've done something wrong and I just let it propagate to the default UncaughtExceptionHandler
which will crash my app and report the issue to our crash reporting platform