100DaysOfSwift-and-SwiftUI/100DaysOfSwift/Day5/Running throwing functions....

11 lines
397 B
Swift

// Running throwing functions
// https://www.hackingwithswift.com/sixty/5/9/running-throwing-functions
do {
try checkPassword("password")
print("That password is good!")
} catch {
print("You can't use that password.")
}
// do starts a section of code that might cause problems, try is used before every function that might throw an error, and catch lets you handle errors gracefully.