nullable Of
Suspend runner that catches and normalizes most thrown exceptions into a null value.
Will NOT catch CancellationException if the coroutine is no longer active!
Does NOT catch Error subclasses. Errors should be fatal.
val a: String? = nullableOf { throw Exception() } // == null
val b: String? = nullableOf { "Hello, World!" } // == "Hello, World!"Content copied to clipboard
Shorthand for try { block() } catch (_: Exception) { null } with an ensureActive guard on CancellationException.