Skip to content

Provide CustomNSError default implementation #1134

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
Jul 28, 2017

Conversation

zayass
Copy link
Contributor

@zayass zayass commented Jul 26, 2017

@ianpartridge
Copy link
Contributor

Can we add some tests in this area?

@zayass
Copy link
Contributor Author

zayass commented Jul 26, 2017

@ianpartridge I add some tests but have no environment to properly run it. Can you trigger CI build?

// conflict resolution
var _code: Int {
return errorCode
}
Copy link
Contributor

@xwu xwu Jul 27, 2017

Choose a reason for hiding this comment

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

Can you fix the indenting on these lines? They should match the rest of the file by using four spaces instead of tabs.

return numericCast(self.rawValue)
}

// conflict resolution
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this comment mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this method fixes compilation issue which @ianpartridge posted

As I understand this two extensions
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSError.swift#L282
https://github.com/apple/swift/blob/master/stdlib/public/core/ErrorType.swift#L220
conflict with each other because no one is more specific

This is more specific so wins them all and "resolve conflict"

// conflict resolution
var _code: Int {
return errorCode
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here.

@ianpartridge
Copy link
Contributor

@swift-ci please test

@ianpartridge
Copy link
Contributor

@zayass

TestFoundation/TestNSError.swift:75:14: error: type 'SwiftError' does not conform to protocol 'Error'
        enum SwiftError : Int, Error, CustomNSError {
             ^
Swift.Error:101:16: note: multiple matching properties named '_code' with type 'Int'
    public var _code: Int { get }
               ^
Swift.Error:2:16: note: candidate exactly matches
    public var _code: Int { get }
               ^
Swift.Error:2:16: note: candidate exactly matches
    public var _code: Int { get }
               ^
Foundation.Error:5:16: note: candidate exactly matches
    public var _code: Int { get }
               ^
TestFoundation/TestNSError.swift:85:14: error: type 'SwiftError' does not conform to protocol 'Error'
        enum SwiftError : UInt, Error, CustomNSError {
             ^
Swift.Error:101:16: note: multiple matching properties named '_code' with type 'Int'
    public var _code: Int { get }
               ^
Swift.Error:2:16: note: candidate exactly matches
    public var _code: Int { get }
               ^
Swift.Error:2:16: note: candidate exactly matches
    public var _code: Int { get }
               ^
Foundation.Error:5:16: note: candidate exactly matches
    public var _code: Int { get }
               ^

@zayass
Copy link
Contributor Author

zayass commented Jul 27, 2017

@ianpartridge fix it. Just forgot public for _code extesnion

@ianpartridge
Copy link
Contributor

@swift-ci please test

Copy link
Contributor Author

@zayass zayass left a comment

Choose a reason for hiding this comment

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

return numericCast(self.rawValue)
}

// conflict resolution
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this method fixes compilation issue which @ianpartridge posted

As I understand this two extensions
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSError.swift#L282
https://github.com/apple/swift/blob/master/stdlib/public/core/ErrorType.swift#L220
conflict with each other because no one is more specific

This is more specific so wins them all and "resolve conflict"

@ianpartridge
Copy link
Contributor

@swift-ci please test

@alblue
Copy link
Contributor

alblue commented Jul 28, 2017

Looks good to me. WDYT @ianpartridge ?


func test_CustomNSError_userInfo() {
let userInfo = SwiftCustomNSError().errorUserInfo
XCTAssertTrue(userInfo.isEmpty)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix the indentation of this line?

func test_CustomNSError_errorCodeRawInt() {
enum SwiftError : Int, Error, CustomNSError {
case minusOne = -1
case fourtyTwo = 42
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling: fortyTwo 🙂


func test_CustomNSError_errorCodeRawUInt() {
enum SwiftError : UInt, Error, CustomNSError {
case fourtyTwo = 42
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling: fortyTwo 🙂

@ianpartridge
Copy link
Contributor

Minor tweaks but otherwise this looks good to me 👍

@zayass
Copy link
Contributor Author

zayass commented Jul 28, 2017

@ianpartridge fixed

@ianpartridge
Copy link
Contributor

@swift-ci please test and merge

@swift-ci swift-ci merged commit 7d4da50 into swiftlang:master Jul 28, 2017
@ianpartridge
Copy link
Contributor

Thanks @zayass 👍

@zayass
Copy link
Contributor Author

zayass commented Jul 31, 2017

May be I can cherry pick this to 3.1 branch. or it is closed?

@ianpartridge
Copy link
Contributor

There isn't going to be another release from the 3.1 branch, I'm afraid.

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.

5 participants