Skip to content

Instantly share code, notes, and snippets.

@hvsw
Last active February 18, 2016 06:53
Show Gist options
  • Save hvsw/f2271ef8ff7402503c4e to your computer and use it in GitHub Desktop.
Save hvsw/f2271ef8ff7402503c4e to your computer and use it in GitHub Desktop.
func calculate() {
do {
let x = 2
let y = 2
let result = try divide(x, y)
resultLabel.text = String(result)
} catch DivisionErrorEnum.DividendIsZero(let code) {
print("Your message when the DIVIDEND is zero. \nDetails: Execution failed with code \(code).")
} catch DivisionErrorEnum.DivisorIsZero(let code) {
print("Your custom message when the DIVISOR is zero. \nDetails: Execution failed with code \(code).")
} catch let error {
print("Another error occurred. SOS!\n\(error.localizedDescription)”)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment