What is error handling?
Error handling is the art of failing gracefully. You have complete control of your code, but you don’t have complete control of anything outside of your code. This includes user input, network connections and any external files your app needs to access.
Imagine you’re in the desert and you decide to surf the Internet. You’re miles away from the nearest Wi-Fi spot. You have no cellular signal. You open your Internet browser. What happens? Does your browser hang there forever with a spinning wheel of death, or does it immediately alert you to the fact that you have no Internet access?
These are things you need to consider when you’re designing the user experience for your apps, as well as the interfaces of your classes and structs. Think about what can go wrong and how you want your app to respond to it.