Flow and exception suppression


I was checking the documentation of the Flow: Flow

And there is statement that I don’t understand in general:

All exception-handling Flow operators follow the principle of exception suppression:
If the upstream flow throws an exception during its completion when the downstream exception has been thrown, the downstream exception becomes superseded and suppressed by the upstream exception, being a semantic equivalent of throwing from finally block. However, this doesn’t affect the operation of the exception-handling operators, which consider the downstream exception to be the root cause and behave as if the upstream didn’t throw anything.

How does it work?I don’t understand how it could throw on completion during the downstream exception and how exception-handling operations work with downstream exceptions suppressing the upstream.


Dumb example;

flowOf(1, 2, 3).onCompletion {
    if (it != null) exceptionReporter.report(it) <---- this can throw exception
.map { it * it }
.onCompletion { if (it > 4) throw RuntimeException("too big!!") }