kotlin function throws exception code example
Example 1: Kotlin try
try {
// some code
}
catch (e: SomeException) {
// handler
}
finally {
// optional finally block
}
Example 2: Kotlin throws
@Throws(SomeException::class)
fun raise() {
throw SomeException("Mwehp!")
}
Example 3: kotlin throw exception
throw Exception("Exception message")