dephinera
07/04/2023, 6:38 PMRaise
way of handling errors. When dealing with multiple types of errors, so far there hasn’t been a solution that would allow to declare that a function or a flow can result in X amount of error types (something that Union types would solve). It seems that context receivers might provide a solution for this by declaring multiple Raise<ErrorT>
contexts. This is fine for functions but it runs short for flows. If a flow can result in either ErrorA
, ErrorB
or Result
, and we don’t want to interrupt it on error, just handle the error value and wait for the next one, then, from my understanding, it looks like we can’t use Raise DSL straight away. So I tried to think of a solution for this and that resulted in creating a custom class that will be used instead of Raise
and will provide the necessary functions so the flow can use it when it encounters an error. At some point this started to feel like I’m abusing both context receivers and Raise DSL 😅 So is there a recommended way of doing this? Basically if I have a flow A
(Flow<String>
, where ErrorA
can occur) and flow B
(Flow<String>
, where ErrorB
can occur), can I use context receivers to handle both errors when I collect the flow, without introducing a new type (like a sealed class), that would unionize the two errors?Youssef Shoaib [MOD]
07/04/2023, 8:12 PMeither
inside the flows, thus emitting an either, and simply bind
on the other side. Another way could be to emit functions of the form context(Raise<Error1>) () -> R
and thus you'd have to invoke
them on the collecting side.
Ideally, there could be some Raise-based flow implementation that deals with all those problems by having its methods need a Raise
to be calleddephinera
07/05/2023, 5:47 AMYoussef Shoaib [MOD]
07/05/2023, 6:00 AMAlejandro Serrano Mena
07/05/2023, 7:30 AMRaise
, to have exactly the bheavior you wantAlejandro Serrano Mena
07/05/2023, 7:31 AMAlejandro Serrano Mena
07/05/2023, 7:31 AMCLOVIS
07/05/2023, 8:02 AM