https://kotlinlang.org logo
#arrow
Title
# arrow
c

Charlie Christensen

07/08/2022, 2:27 PM
I am experiencing a crash when using
parZip
inside of an
either
block.
Copy code
suspend fun refresh(): Either<Throwable, Unit> = either {
    parZip(
        { refreshA().bind() },
        { refreshB().bind() }
    ) { dataA, dataB ->
        persistData(dataA, dataB).bind()
    }
}
But if one of the suspending functions doesnt return the proper type, the exception is not caught. The crash happens with an unsafe cast at line 85 of
ParZip.kt
f(a as A, b as B)
Is there any way to catch this exception? I feel like I would need to double wrap the Either
s

simon.vergauwen

07/10/2022, 7:00 PM
Hey @Charlie Christensen, I am unsure what this is related to. The code you shared should be correct, as it should be safe to use
parZip
inside of
either { }
. Could you share a longer or reproducible example so this could be investigated?
7 Views