Understanding Error Handling in Swift

Gain an understanding of how to trigger and handle errors gracefully within Swift code. Additionally , see how to design code to throw and catch errors to take corrective action or explain the nature of the problem encountered to the user.

In a perfect world, running code would never encounter an error. The reality, however, is that it is impossible to guarantee that an error of some form or another will not occur at some point during the execution of the app. Therefore, it is essential to ensure that the code of an app is implemented such that it gracefully handles any errors that may occur. Since the introduction of Swift 2, the task of handling errors has become much easier for the Swift developer.

This lesson will cover the handling of errors using Swift and introduce topics such as error types, throwing methods and functions, the guard, defer, and do-catch statements.

Get hands-on with 1200+ tech skills courses.