enum Exception: Error {
case text
}
func throwIfTrue(_ param: Bool) throws {
defer {
print("defer")
}
do {
if param {
throw Exception.text
}
}
catch {
print("catch")
}
}
try! throwIfTrue(true)
//printed: "catch" and "defer"
try! throwIfTrue(false)
//printed only "defer"