>>108892800
yes that's actually not the same as a precondition.
preconditions immediately crash your application, like trying to index an array out of bounds. thrown errors can be caught.
let x = 2
do {
if x > 1 { throw NSError(domain: "Fuck1", code: 0) }
print("pass1")
} catch {
print("error caught \(error)") //prints
}
do {
precondition (x < 1, "fuck2") //crashes
print("pass2") //never called
} catch {
print(error) //never called
}
console output:
error caught Error Domain=Fuck1 Code=0 "(null)"
__lldb_expr_73/Tests.playground:24: Precondition failed: fuck2
You can use fatalError() to throw an uncatchable error though.