error

inline fun error(message: Any): Nothing(source)

Throws an IllegalStateException with the given message.

Since Kotlin

1.1

Samples

import kotlin.test.*

fun main() { 
   //sampleStart 
   val name: String? = null

// val nonNullName = name ?: error("Name is missing") // will fail with IllegalStateException 
   //sampleEnd
}
inline fun error(message: Any): Nothing(source)

Throws an IllegalStateException with the given message.

Since Kotlin

1.0

Samples

import kotlin.test.*

fun main() { 
   //sampleStart 
   val name: String? = null

// val nonNullName = name ?: error("Name is missing") // will fail with IllegalStateException 
   //sampleEnd
}