[swift-evolution] [Proposal draft] NSError bridging

Charles Srstka cocoadev at charlessoft.com
Wed Jun 29 06:13:21 CDT 2016


> On Jun 29, 2016, at 2:50 AM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I'm not sure I really want '.url' and '.stringEncoding' on every
> Error.  'var underlying' is universally useful, but providing it
> requires a implementing conformance to CustomNSError, which has to
> vend a weakly-typed dictionary.  Is this really the API we want to
> expose?

We need to expose the dictionary in order to provide full compatibility with NSError.

> Also, the underlying error has to be stored somewhere, which
> effectively prevents implementers of CustomNSError from being enums.


Not at all. Your enum can implement a dynamic errorUserInfo property that will populate the dictionary with the appropriate values. If you need to actually store something, that can be done with enum cases as well.

Charles

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160629/59835a27/attachment.html>


More information about the swift-evolution mailing list