Skip to content

Instantly share code, notes, and snippets.

@mahmudahsan
Created December 22, 2017 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmudahsan/73216779621add9ffa386414945457b0 to your computer and use it in GitHub Desktop.
Save mahmudahsan/73216779621add9ffa386414945457b0 to your computer and use it in GitHub Desktop.
Error handling in swift
func square(val:Int) throws -> Int {
if val == 5 {
throw SampleError.sample1
}
return val * val
}
let sqaureValue = try! square(val: 10)
print(sqaureValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment