How to print details of a ‘catch all’ exception in Swift?

I just figured it out. I noticed this line in the Swift Documentation:

If a catch clause does not specify a pattern, the clause will match and bind any error to a local constant named error

So, then I tried this:

do {
    try vend(itemNamed: "Candy Bar")
...
} catch {
    print("Error info: \(error)")
}

And it gave me a nice description.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)