Skip to content

[Runtime] Error bridged to NSError should return its description rather than NSError description #29224

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
merged 1 commit into from
Jan 16, 2020

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Jan 15, 2020

An Error bridged to NSError currently prints the NSError description, where as it should print the Error description. For example:

enum DecodingError: Error, CustomStringConvertible {
  case keyNotFound

  var description: String {
    switch self {
      case .keyNotFound: 
        return "Key not found"
    }
  }
}

// Prints: Error Domain=test.DecodingError Code=0 "(null)"
// instead of: "Key not found"
print((DecodingError.keyNotFound as NSError).description)

Resolves SR-7652

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@theblixguy
Copy link
Collaborator Author

@swift-ci please test

@theblixguy
Copy link
Collaborator Author

@swift-ci please test macOS

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