<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="" applecontenteditable="true"><div class="">'localizedDescription' isn't a requirement of the Error protocol, which means it's not a customization point. You need to actually conform to LocalizedError and provide a valid 'errorDescription' instead.</div><div class=""><br class=""></div><div class="">(It's too bad that your second test works at all, since MyError doesn't conform to LocalizedError. Unfortunately NSError <i class="">does</i>&nbsp;conform to LocalizedError, and all Errors can be bridged to NSError.)</div><div class=""><br class=""></div><div class="">If you're interested, you can find more information about the design in its proposal,&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md" class="">SE-0112</a>.</div><div class=""><br class=""></div><div class="">Hope this helps,</div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 28, 2017, at 12:54, Jon Shier via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Swifters:<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>I have a custom error enum:<br class=""><br class="">enum MyError: Error {<br class=""><br class=""> &nbsp;&nbsp;&nbsp;case network(error: Error)<br class=""> &nbsp;&nbsp;&nbsp;case json(error: Error)<br class=""> &nbsp;&nbsp;&nbsp;case value(error: Error)<br class=""><br class=""> &nbsp;&nbsp;&nbsp;var localizedDescription: String {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch self {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case let .network(error): return error.localizedDescription<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case let .json(error): return error.localizedDescription<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case let .value(error): return error.localizedDescription<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;&nbsp;&nbsp;}<br class=""><br class="">}<br class=""><br class="">However, the localizedDescription output is odd to me. When the value is treated as:<br class=""><br class="">Error: &nbsp;po error.localizedDescription<br class="">"The operation couldn’t be completed. (MyApp.MyError error 1.)”<br class=""><br class="">LocalizedError: &nbsp;po (error as! LocalizedError).localizedDescription<br class="">"The operation couldn’t be completed. (MyApp.MyError error 1.)”<br class=""><br class="">MyError: Error: &nbsp;po (error as! MyError).localizedDescription<br class="">"JSON could not be serialized because of error:\nThe data couldn’t be read because it isn’t in the correct format."<br class=""><br class="">Shouldn’t my implementation of localizedDescription take precedence in all cases here? (This is Xcode 8.3b3).<br class=""><br class=""><br class=""><br class="">Jon<br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></body></html>