Skip to content

Commit 55bead0

Browse files
committed
Deprecate flowWith with ERROR
1 parent 41428a3 commit 55bead0

File tree

4 files changed

+22
-386
lines changed

4 files changed

+22
-386
lines changed

kotlinx-coroutines-core/common/src/flow/operators/Context.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public fun <T> Flow<T>.flowOn(context: CoroutineContext): Flow<T> {
238238
* 4) It can be confused with [flowOn] operator, though [flowWith] is much rarer.
239239
*/
240240
@FlowPreview
241-
@Deprecated(message = "flowWith is deprecated without replacement, please refer to its KDoc for an explanation", level = DeprecationLevel.WARNING) // Error in beta release, removal in 1.4
241+
@Deprecated(message = "flowWith is deprecated without replacement, please refer to its KDoc for an explanation", level = DeprecationLevel.ERROR) // Error in beta release, removal in 1.4
242242
public fun <T, R> Flow<T>.flowWith(
243243
flowContext: CoroutineContext,
244244
bufferSize: Int = BUFFERED,

kotlinx-coroutines-core/common/test/flow/operators/FlowContextTest.kt

Lines changed: 0 additions & 154 deletions
This file was deleted.

kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,27 @@ class FlowOnTest : TestBase() {
261261
finish(3)
262262
}
263263

264+
@Test
265+
fun testException() = runTest {
266+
val flow = flow {
267+
emit(314)
268+
delay(Long.MAX_VALUE)
269+
}.flowOn(NamedDispatchers("upstream"))
270+
.map {
271+
throw TestException()
272+
}
273+
274+
assertFailsWith<TestException> { flow.single() }
275+
assertFailsWith<TestException>(flow)
276+
ensureActive()
277+
}
278+
279+
@Test
280+
fun testIllegalArgumentException() {
281+
val flow = emptyFlow<Int>()
282+
assertFailsWith<IllegalArgumentException> { flow.flowOn(Job()) }
283+
}
284+
264285
private inner class Source(private val value: Int) {
265286
public var contextName: String = "unknown"
266287

0 commit comments

Comments
 (0)