App developers deal with errors from UIKit and other Objective-C libraries. Find out how they work with Swift.
This is a companion discussion topic for the original entry at https://www.kodeco.com/1940818-advanced-swift-error-handling/lessons/5
App developers deal with errors from UIKit and other Objective-C libraries. Find out how they work with Swift.
Not entirely sure when it has changed, but it looks like catching an error with associated value as an NSError no longer loses the associated value.
enum FancyError: Error {
case kazam(String)
}
do {
throw FancyError.kazam("Help")
}
catch (let error as NSError) {
dump(error)
}
Outputs:
- __lldb_expr_28.FancyError.kazam("Help") #0
- super: NSError
- super: NSObject