Merge pull request #93 from JetBrains/try-catch-finally

Implement throw and try-catch-finally in backend

add corresponding tests
This commit is contained in:
SvyatoslavScherbina
2016-11-29 15:01:23 +07:00
committed by GitHub
29 changed files with 1252 additions and 187 deletions
@@ -0,0 +1,16 @@
fun main(args : Array<String>) {
try {
println("Before")
foo()
println("After")
} catch (e: Throwable) {
println("Caught Throwable")
}
println("Done")
}
fun foo() {
throw Error("Error happens")
println("After in foo()")
}
@@ -0,0 +1,20 @@
fun main(args : Array<String>) {
try {
println("Before")
foo()
println("After")
} catch (e: Exception) {
println("Caught Exception")
} catch (e: Error) {
println("Caught Error")
} catch (e: Throwable) {
println("Caught Throwable")
}
println("Done")
}
fun foo() {
throw Error("Error happens")
println("After in foo()")
}
@@ -0,0 +1,14 @@
fun main(args : Array<String>) {
try {
foo()
} catch (e: Throwable) {
val message = e.message
if (message != null) {
println(message)
}
}
}
fun foo() {
throw Error("Error happens")
}