What is error handling? It is a process of properly handling unusual conditions in the program. There is an old saying: Garbage in, garbage out. Computers are machines that are very good at processing commands without questioning the input that is given to it. So if you give them bad data (garbage data), they will process it and give you bad results (garbage out). So it is the programmer’s responsibility to put guards against invalid or erroneous situations. Swift provides first-class support for handling these situations.
Let’s take a situation of downloading data from a remote server. If everything went correct, you would have data and then you could process it, but there can be various errors: