{"id":13449,"date":"2016-02-08T13:29:27","date_gmt":"2016-02-08T18:29:27","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=13449"},"modified":"2016-02-08T13:29:27","modified_gmt":"2016-02-08T18:29:27","slug":"from-result-to-throw-and-back","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/02\/08\/from-result-to-throw-and-back\/","title":{"rendered":"From &ldquo;Result&rdquo; to &ldquo;throw&rdquo; and Back"},"content":{"rendered":"<p><a href=\"http:\/\/alisoftware.github.io\/swift\/async\/error\/2016\/02\/06\/async-errors\/\">Olivier Halligon<\/a>:<\/p>\n<blockquote cite=\"http:\/\/alisoftware.github.io\/swift\/async\/error\/2016\/02\/06\/async-errors\/\">\n<p>Problem is, <code>Result<\/code> is not built in the Swift standard library, and a lot of functions use <code>throw<\/code> to report synchronous errors anyway. Like in practice, to build a <code>User<\/code> from a <code>NSDictionary<\/code> we might have a <code>init(dict: NSDictionary) throws<\/code> constructor instead of a <code>NSDictionary -&gt; Result&lt;User&gt;<\/code> function.<\/p>\n<p>So how to mix both those worlds? Easy: let&rsquo;s extend <code>Result<\/code> just for that!<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Olivier Halligon: Problem is, Result is not built in the Swift standard library, and a lot of functions use throw to report synchronous errors anyway. Like in practice, to build a User from a NSDictionary we might have a init(dict: NSDictionary) throws constructor instead of a NSDictionary -&gt; Result&lt;User&gt; function. So how to mix both [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","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":[46,857,71,901],"class_list":["post-13449","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-nserror","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13449","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=13449"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13449\/revisions"}],"predecessor-version":[{"id":13450,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13449\/revisions\/13450"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=13449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=13449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=13449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}