-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
Can we add some tests in this area? |
@ianpartridge I add some tests but have no environment to properly run it. Can you trigger CI build? |
Foundation/NSError.swift
Outdated
// conflict resolution | ||
var _code: Int { | ||
return errorCode | ||
} |
There was a problem hiding this comment.
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.
Foundation/NSError.swift
Outdated
return numericCast(self.rawValue) | ||
} | ||
|
||
// conflict resolution |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"
Foundation/NSError.swift
Outdated
// conflict resolution | ||
var _code: Int { | ||
return errorCode | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here.
@swift-ci please test |
|
@ianpartridge fix it. Just forgot |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found better solution in original https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSError.swift
Foundation/NSError.swift
Outdated
return numericCast(self.rawValue) | ||
} | ||
|
||
// conflict resolution |
There was a problem hiding this comment.
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"
@swift-ci please test |
Looks good to me. WDYT @ianpartridge ? |
TestFoundation/TestNSError.swift
Outdated
|
||
func test_CustomNSError_userInfo() { | ||
let userInfo = SwiftCustomNSError().errorUserInfo | ||
XCTAssertTrue(userInfo.isEmpty) |
There was a problem hiding this comment.
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?
TestFoundation/TestNSError.swift
Outdated
func test_CustomNSError_errorCodeRawInt() { | ||
enum SwiftError : Int, Error, CustomNSError { | ||
case minusOne = -1 | ||
case fourtyTwo = 42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: fortyTwo
🙂
TestFoundation/TestNSError.swift
Outdated
|
||
func test_CustomNSError_errorCodeRawUInt() { | ||
enum SwiftError : UInt, Error, CustomNSError { | ||
case fourtyTwo = 42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: fortyTwo
🙂
Minor tweaks but otherwise this looks good to me 👍 |
Pull default CustomNSError implementation from https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSError.swift
@ianpartridge fixed |
@swift-ci please test and merge |
Thanks @zayass 👍 |
May be I can cherry pick this to 3.1 branch. or it is closed? |
There isn't going to be another release from the 3.1 branch, I'm afraid. |
Pull default CustomNSError implementation from https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSError.swift