Обработка ошибок

enum ExceptionError {
    case text
}

func throwIfTrue(_ param: Boolthrows {
    defer {
        print("defer")
    }
    do {
        if param {
            throw Exception.text
        }
    }
    catch {
        print("catch")
    }


trythrowIfTrue(true)
//printed: "catch" and "defer"
trythrowIfTrue(false)
//printed only "defer"