fun list(): Either<Error, Flow<Item>> = either {
flow {
if (someSuspendFun()) this@either.raise(Error)
emitAll(someList())
}
}
it says
arrow.core.raise.RaiseLeakedException: 'raise' or 'bind' was leaked outside of its context scope. Make sure all calls to 'raise' and 'bind' occur within the lifecycle of nullable { }, either { } or similar builders.
or is the way to go to make the function suspend and do the check before the flow block?
s
simon.vergauwen
06/11/2025, 3:18 PM
Either needs to stay inside Flow, so
Flow<Either<E, A>>
, or you need to call collect inside
either
itself.
s
S.
06/11/2025, 3:21 PM
I'm not collecting it here, just passing the flow on but would this then be okay
Copy code
suspend fun list(): Either<Error, Flow<Item>> = either {
if (someSuspendFun()) raise(Error)
someList()
}
or is
Either<E, Flow<A>>
a bad idea in general?
s
simon.vergauwen
06/11/2025, 3:22 PM
No, that works great! It depends on your use-case to be honest.
This is perfect if constructing the Flow can go wrong, Flow<Either<E, A>> is great if you need to model error as part of your stream without stopping (Exception).
s
S.
06/11/2025, 3:23 PM
alright, thanks! and yeah in that case I want to stop the entire request if permissions are missing