if you really wanted, you could combine the two to...
# announcements
d
if you really wanted, you could combine the two to get the reified behavior 😆
Copy code
inline fun <T> tryOrNullWhen(vararg ignore: KClass<out Throwable>, body: () -> T): T? =
  try { body() } catch (e: Exception) { if(ignore.any { it.java.isInstance(e) }) null else throw e }

inline fun <T , reified E : Throwable> tryOrNull(body: () -> T): T? = tryOrNullWhen<T>(E::class, body)