Skip to content

Commit

Permalink
Update kotlinx-coroutines-core/common/src/flow/Flow.kt
Browse files Browse the repository at this point in the history
Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
  • Loading branch information
qwwdfsad and dkhalanskyjb authored Nov 12, 2021
1 parent b3eade1 commit 08a3ed3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kotlinx-coroutines-core/common/src/flow/Flow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ import kotlin.coroutines.*
*
* ### Exception transparency
*
* Flow implementations never explicitly catch and ignore exceptions that occur in downstream flows.
* From the implementation standpoint, it means that `catch` blocks that wrap calls to [emit][FlowCollector.emit] and [emitAll]
* are not allowed to complete normally or attempt to call [emit][FlowCollector.emit], they are only allowed
* to rethrow a caught exception or throw a different exception for diagnostics or application-specific purposes.
* When `emit` or `emitAll` throws, the Flow implementations must immediately stop emitting new values and finish with an exception.
* For diagnostics or application-specific purposes, the exception may be different from the one thrown by the emit operation,
* but then it will be suppressed, as discussed below.
* If there is a need to emit values after the downstream failed, please use the [catch][Flow.catch] operator.
*
*
* Exception handling with further emission in flows shall only be performed with
* [catch][Flow.catch] operator, and it is designed to only catch exceptions coming from upstream flows while passing
* The [catch][Flow.catch] operator only catches upstream exceptions, but passes
* all downstream exceptions. Similarly, terminal operators like [collect][Flow.collect]
* throw any unhandled exceptions that occur in their code or in upstream flows, for example:
*
Expand Down

0 comments on commit 08a3ed3

Please sign in to comment.