refs #22 try without catch but finally
This commit is contained in:
parent
0981d8370e
commit
88974e0f2d
@ -106,6 +106,22 @@ This way, in turn, can also be shortened, as it is overly popular:
|
||||
The trick, though, works with strings only, and always provide `Exception` instances, which is good for debugging but
|
||||
most often not enough.
|
||||
|
||||
## finally block
|
||||
|
||||
If `finally` block present, it will be executed after body (until first exception)
|
||||
and catch block, if any will match. finally statement is executed even if the
|
||||
exception will be thrown and not caught locally. It does not alter try/catch block result:
|
||||
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
println("called finally")
|
||||
}
|
||||
>>> called finally
|
||||
>>> void
|
||||
|
||||
- and yes, there could be try-finally block, no catching, but perform some guaranteed cleanup.
|
||||
|
||||
# Custom error classes
|
||||
|
||||
_this functionality is not yet released_
|
||||
|
@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
group = "net.sergeych"
|
||||
version = "0.5.1-SNAPSHOT"
|
||||
version = "0.5.2-SNAPSHOT"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
|
@ -790,8 +790,6 @@ class Compiler(
|
||||
t = cc.next()
|
||||
}
|
||||
}
|
||||
if( catches.isEmpty() )
|
||||
throw ScriptError(cc.currentPos(), "try block must have at least one catch clause")
|
||||
val finallyClause = if( t.value == "finally" ) {
|
||||
parseBlock(cc)
|
||||
} else {
|
||||
@ -799,6 +797,9 @@ class Compiler(
|
||||
null
|
||||
}
|
||||
|
||||
if( catches.isEmpty() && finallyClause == null )
|
||||
throw ScriptError(cc.currentPos(), "try block must have either catch or finally clause or both")
|
||||
|
||||
return statement {
|
||||
var result: Obj = ObjVoid
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user