Skip to content

Instantly share code, notes, and snippets.

@sigidhanafi
Last active April 20, 2022 14:55
Show Gist options
  • Save sigidhanafi/7f60f0da50eca098bd20075628513e5e to your computer and use it in GitHub Desktop.
Save sigidhanafi/7f60f0da50eca098bd20075628513e5e to your computer and use it in GitHub Desktop.
handle error in swift
// Step 3 use do try catch
let urlString = ""
do {
let result = try validateUrl(urlString: urlString)
// Step 5 continue the process if it success
print("is url valid? \(result)")
}
catch {
// Step 4 show error to users
print("error \(error)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment