check

Throws an IllegalStateException if the value is false.

inline fun check(value: Boolean)(source)
fun processAmount(amount: Int) {
    // Ensure the amount is positive before proceeding
    check(amount > 0)

    println("Processing amount: $amount")
}

fun main() {
    processAmount(10)   // Works fine
    processAmount(-5)   // Throws IllegalStateException
}

Source