Skip to content

EncodingError/DecodingError bridging fixes and conveniences #10685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

itaiferber
Copy link
Contributor

What's in this pull request?
As laid out in a proposed update to SE-0166 and SE-0167, there are EncodingError/DecodingError updates that we wanted to introduce to the Codable API. This implements the remainder of those updates which had not yet been implemented:

  • underlyingError exposition on EncodingError and DecodingError
  • .dataCorrupted conveniences for user code
  • Fixing error bridging to NSError

This subsumes #10674.

Itai Ferber added 4 commits June 28, 2017 14:31
Some errors are caused by others — this allows us to expose the underlying problem.
CustomNSError briding only works when the CustomNSError conformance is in the same module as the original error declaration. We need to sink these down into the standard library.
DecodingError.dataCorrupted is an error most commonly thrown from user code. We can expose conveniences to more easily throw .dataCorrupted errors.
If JSONSerialization or PropertyListSerialization throw errors during encoding or decoding, the error should be exposed as an EncodingError or DecodingError
@itaiferber
Copy link
Contributor Author

This is the correct version which should work on Linux as well.

@itaiferber
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@phausler phausler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me


return userInfo as AnyObject
#else
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a callback here to hook a return for swift-corelibs-foundation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in person, since we don't have error bridging on Linux anyway, nothing would hit that callback, unfortunately. I think this should be one of our focus points for the next release, and once we have more infrastructure in place, we should definitely put a hook in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants