Is there anything in the Orbit Testing library tha...
# orbit-mvi
b
Is there anything in the Orbit Testing library that prevents an intent from throwing an Exception and crashing? One of my
intent
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 passes
m
We don’t do any special exception handling in tests.
I’m not sure rethrowing the exception in the handler will cause a test to crash.
b
Thanks for your help, what is the default behaviour in Orbit when an Exception in thrown if no
exceptionHandler
has been provided? Not necessarily talking about a test container here, more in general
m
This should crash the application, I believe
b
ok thanks 🙂
m
An
ExceptionHandler
is given as an option - my personal preference is to handle exceptions locally in intents, and crash otherwise.
m
to handle exceptions locally in intents
does below is an equivalent snippet @Mikolaj Leszczynski mentioned(?)
Copy code
fun doSomething() = intent {
   runCatching { useCase/repo.doSomething() }
      .onFailure {}
      .onSuccess {}
}
m
can be that, or a regular try/catch
b
Personal opinion here, to elaborate on that: I write my code in such a way that it shouldn't crash, if the code I have to deal with can crash, like I/O operations, I wrap it in an
Either
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
🙏 1
today i learned 1
👍 1