[swift-evolution] [Proposal] Foundation Swift Encoders

Zach Waldowski zach at waldowski.me
Thu Mar 16 00:46:41 CDT 2017

Just a little one that came up with when thinking over the companion proposal… see inline.

> On Mar 15, 2017, at 6:43 PM, Itai Ferber via swift-evolution <swift-evolution at swift.org> wrote:
> Foundation-Provided Errors
> Along with providing the above encoders and decoders, we would like to promote the use of a common set of error codes and messages across all new encoders and decoders. A common vocabulary of expected errors allows end-users to write code agnostic about the specific encoder/decoder implementation they are working with, whether first-party or third-party:
> extension CocoaError.Code {
>     public static var coderInvalidValue: CocoaError.Code
>     public static var coderTypeMismatch: CocoaError.Code
>     public static var coderReadCorrupt: CocoaError.Code
>     public static var coderValueNotFound: CocoaError.Code
> }

I find all the reasons compelling, but I don’t with the overall choice. A common vocabulary, side table info, and localization can be achieved with a dedicated error type for coders. I understand ABI (sorta) concerns are involved here, that older Foundations will continue to return the same NSError codes. However, it's never felt appropriate to create my own error instances with NSCocoaErrorDomain, and this feels very similar to that. What are our options here?

Zach Waldowski
zach at waldowski.me

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

More information about the swift-evolution mailing list