2
如何在Swift中打印'catch all'异常的详细信息?
我正在更新代码以使用Swift,并且我想知道如何为与'catch all'子句匹配的异常打印错误详细信息。我已经对该Swift语言指南页面中的示例进行了稍微修改,以说明我的观点: do { try vend(itemNamed: "Candy Bar") // Enjoy delicious snack } catch VendingMachineError.InvalidSelection { print("Invalid Selection.") } catch VendingMachineError.OutOfStock { print("Out of Stock.") } catch VendingMachineError.InsufficientFunds(let amountRequired) { print("Insufficient funds. Please insert an additional $\(amountRequired).") } catch { // HOW DO I PRINT OUT INFORMATION ABOUT THE ERROR …