I hope we have delivered on the promises made at the beginning of this chapter, and that you have begun to appreciate the value, importance, and sheer elegance of Swift's error-handling support.
In this chapter, you have learned the following:
- When to use optionals and when to use explicit error handling
- How to create custom error types of varying complexity
- How to throw an Error type in your code
- The four ways of handling a Swift Error
- How to catch or rethrow an error
- Using pattern matching to distinguish between error types
- Using an error's associated types to convey information
- How to handle and write NSError code
You'll be glad about this in the next chapter, in which we address the topics of file storage - both local and in the cloud - areas in which clear error-handling code are of the utmost importance. Read on!