fun throwIfTrue(param: Boolean) {
try {
if (param) {
throw Exception("test exception")
}
}
catch (e: Exception) {
println("catch")
}
finally {
println("finally")
}
}
throwIfTrue(true)
//printed: "catch" and "finally"
throwIfTrue(false)
//printed only "finally"