alakazam.kotlin.core.ThrowChecks.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-core Show documentation
Show all versions of kotlin-core Show documentation
A set of useful functions and extensions for Kotlin development.
@file:Suppress("TooGenericExceptionThrown")
package alakazam.kotlin.core
public inline fun throwsSpecific(block: () -> Unit): Boolean = try {
block()
false
} catch (e: Throwable) {
Expected::class.isInstance(e)
}
public fun throwsAnyException(block: () -> Unit): Boolean = try {
block()
false
} catch (e: Exception) {
true
}
public fun throwsAnyThrowable(block: () -> Unit): Boolean = try {
block()
false
} catch (e: Throwable) {
true
}