Skip to content

[4.0] EncodingError/DecodingError bridging fixes and conveniences #10704

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

Conversation

itaiferber
Copy link
Contributor

@itaiferber itaiferber commented Jun 29, 2017

What's in this pull request?
Cherry-picks #10685 to swift-4.0-branch.

Explanation:
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

Scope: Affects those consuming EncodingError/DecodingError and want to present those to the user in a localized way.
Radars:

  • rdar://problem/32405015
  • rdar://problem/32512651
  • rdar://problem/32381842
  • rdar://problem/32235068

Risk: Low
Testing: Manual verification

Itai Ferber added 4 commits June 29, 2017 10:06
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

@swift-ci Please test

@itaiferber itaiferber merged commit db984b3 into swiftlang:swift-4.0-branch Jun 29, 2017
@itaiferber itaiferber deleted the 4.0-codingerror-bridging-and-conveniences branch June 29, 2017 20:38
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