function throwIfTrue(param: boolean) {
try {
if (param)
throw new Error("test exception")
}
catch (e) {
console.log(" -catch")
}
finally {
console.log(" -finally")
}
}
console.log("with exception:")
throwIfTrue(true)
//printed: "catch" and "finally"
console.log("\nwithout exception:")
throwIfTrue(false)
//printed only "finally"