Skip to content

Commit 08a3ed3

Browse files
Update kotlinx-coroutines-core/common/src/flow/Flow.kt
Co-authored-by: dkhalanskyjb <[email protected]>
1 parent b3eade1 commit 08a3ed3

File tree

1 file changed

+5
-7
lines changed
  • kotlinx-coroutines-core/common/src/flow

1 file changed

+5
-7
lines changed

kotlinx-coroutines-core/common/src/flow/Flow.kt

+5-7
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,12 @@ import kotlin.coroutines.*
131131
*
132132
* ### Exception transparency
133133
*
134-
* Flow implementations never explicitly catch and ignore exceptions that occur in downstream flows.
135-
* From the implementation standpoint, it means that `catch` blocks that wrap calls to [emit][FlowCollector.emit] and [emitAll]
136-
* are not allowed to complete normally or attempt to call [emit][FlowCollector.emit], they are only allowed
137-
* to rethrow a caught exception or throw a different exception for diagnostics or application-specific purposes.
134+
* When `emit` or `emitAll` throws, the Flow implementations must immediately stop emitting new values and finish with an exception.
135+
* For diagnostics or application-specific purposes, the exception may be different from the one thrown by the emit operation,
136+
* but then it will be suppressed, as discussed below.
137+
* If there is a need to emit values after the downstream failed, please use the [catch][Flow.catch] operator.
138138
*
139-
*
140-
* Exception handling with further emission in flows shall only be performed with
141-
* [catch][Flow.catch] operator, and it is designed to only catch exceptions coming from upstream flows while passing
139+
* The [catch][Flow.catch] operator only catches upstream exceptions, but passes
142140
* all downstream exceptions. Similarly, terminal operators like [collect][Flow.collect]
143141
* throw any unhandled exceptions that occur in their code or in upstream flows, for example:
144142
*

0 commit comments

Comments
 (0)