{"id":18452,"date":"2017-07-24T16:55:04","date_gmt":"2017-07-24T20:55:04","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=18452"},"modified":"2017-07-26T10:54:02","modified_gmt":"2017-07-26T14:54:02","slug":"matching-and-bridging-nserrors-in-swfit","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/07\/24\/matching-and-bridging-nserrors-in-swfit\/","title":{"rendered":"Matching and Bridging NSErrors in Swift"},"content":{"rendered":"<p><a href=\"http:\/\/www.figure.ink\/blog\/2017\/7\/24\/update-matching-nserrors\">Joshua Emmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.figure.ink\/blog\/2017\/7\/24\/update-matching-nserrors\">\n<p>You can find all the gory details in <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0112-nserror-bridging.md\">SE-0112<\/a>, but the long and the short of it is, depending on the <code>domain<\/code> of a given <code>NSError<\/code>, Swift automatically bridges it to a struct describing that domain. In the case of <code>NSURLErrorDomain<\/code>, for example, Swift will bridge to a <a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/urlerror\" id=\"yui_3_17_2_1_1500929509222_196\">URLError<\/a>[&#8230;]<\/p>\n<\/blockquote>\n\n<p>You can also use the <a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/customnserror\">CustomNSError<\/a> protocol to bridge in the other direction.<\/p>\n<p>See also: <a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/cocoaerror\">CocoaError<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Joshua Emmons: You can find all the gory details in SE-0112, but the long and the short of it is, depending on the domain of a given NSError, Swift automatically bridges it to a struct describing that domain. In the case of NSURLErrorDomain, for example, Swift will bridge to a URLError[&#8230;] You can also use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,46,857,54,71,901],"class_list":["post-18452","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-languagedesign","tag-nserror","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=18452"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18452\/revisions"}],"predecessor-version":[{"id":18466,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18452\/revisions\/18466"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=18452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=18452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=18452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}