Recall & Review
beginner
What is the main purpose of error handling in network calls?
To manage problems like no internet, server errors, or bad data so the app can respond gracefully and inform the user.
Click to reveal answer
beginner
Which Swift type is commonly used to represent success or failure in network calls?
The
Result type, which has two cases: .success for successful data and .failure for errors.Click to reveal answer
intermediate
What Swift keyword is used to catch errors thrown during a network call?
The
do-catch block is used to try code that can throw errors and handle those errors in the catch section.Click to reveal answer
intermediate
Why should you check the HTTP status code in a network response?
Because a network call can succeed at the connection level but still return an error status like 404 or 500, which means the request failed.
Click to reveal answer
beginner
What is a common way to inform users about network errors in an iOS app?
Showing an alert or message on screen explaining the problem, like "No internet connection" or "Server unavailable."
Click to reveal answer
Which Swift type helps handle success and failure in network calls?
✗ Incorrect
The Result type clearly separates success and failure cases, making error handling easier.
What does a 404 HTTP status code mean?
✗ Incorrect
404 means the requested resource was not found on the server.
Which Swift construct is used to catch errors thrown by functions?
✗ Incorrect
do-catch blocks are designed to handle errors thrown by functions.
What should you do if a network call fails due to no internet?
✗ Incorrect
Informing the user helps them understand the problem and possibly fix it.
In Swift, how do you represent an error in a Result type?
✗ Incorrect
The .failure case holds the error information.
Explain how you would handle errors when making a network call in Swift.
Think about how to catch errors, check response, and show messages.
You got /4 concepts.
Describe why it is important to check the HTTP status code after a network call.
Not all network connections that succeed mean the request was successful.
You got /3 concepts.