O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Error handling

Optionals are used to represent the existence/absence of a value. A result of an operation can be optional, so when that operation fails we will receive nil. The optional itself will not provide any information about how our operation failed and what the cause of the failure, and in most of cases it is useful to know the context and cause of the failure to be able to respond accordingly in our code.

Error handling is the process of responding to and recovering from error conditions in our applications. The Swift standard library provides first-class support for throwing, catching, propagating, and manipulating recoverable errors at runtime.

Let's go through an example to explore the error handling concept. Suppose that we need ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required