Hello everyone, I am a Kotlin newbie and are looking for a way to resume a Flow after an exception has been thrown by the emitter. I want to adhere to Exception Transparency. I have seen a workaround on SO (https://stackoverflow.com/a/63886110) but wanted to ask if you know an easier / less custom solution. Thanks!
g
gildor
09/20/2020, 3:25 PM
You can use catch operator to handle exception
c
Christian S.
09/21/2020, 8:49 AM
Thanks, Andrey, but my requirement is to not terminate the flow when an exception in the emitter occurs. When the exception is catched with a catch operator the flow still terminates. To solve this, my colleague just had a simple solution: just emit(..) a default/error value in case an exception has occurred in the emitter before and move the emit(..) call outside of the try-block. This adheres to Exception Transparency.
👍🏾 1
g
gildor
09/21/2020, 8:51 AM
But it’s up to flow terminate or not, right?
The only what you can do is restart flow