79261184

Date: 2024-12-07 18:54:48
Score: 2
Natty:
Report link

For whoever gets the same problem following code was wrong (Thanks to @tyg for finding)

            flow<T?> {
                try {
                    emit("Value")
                } catch (e: Exception) {
                    println("Something went wrong ${e.message}")
                }
            }.firstOrNull()

In this usage CancellationException getting caught and causes the log I posted in question.

The correct usage is at below.

            flow<T?> {
                emit("Value")
            }.catch { e ->
                println("Something went wrong ${e.message}")
            }.firstOrNull()
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @tyg
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Mobile Dev