Skip to content

Commit bbcf916

Browse files
authored
Merge pull request #4611 from compnerd/error
Foundation: rework handling for `ECANCELED`
2 parents 0b5e0ea + 4858113 commit bbcf916

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Sources/Foundation/NSError.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -995,14 +995,6 @@ extension POSIXErrorCode: _ErrorCodeProtocol {
995995
public typealias _ErrorType = POSIXError
996996
}
997997

998-
#if os(Windows)
999-
extension POSIXErrorCode {
1000-
public static var ECANCELED: POSIXErrorCode {
1001-
return POSIXError.Code(rawValue: WinSDK.ECANCELED)!
1002-
}
1003-
}
1004-
#endif
1005-
1006998
extension POSIXError {
1007999
/// Operation not permitted.
10081000
public static var EPERM: POSIXError.Code { return .EPERM }
@@ -1322,7 +1314,13 @@ extension POSIXError {
13221314
#endif
13231315

13241316
/// Operation canceled.
1325-
public static var ECANCELED: POSIXError.Code { return .ECANCELED }
1317+
public static var ECANCELED: POSIXError.Code {
1318+
#if os(Windows)
1319+
return POSIXError.Code(rawValue: ERROR_CANCELLED)!
1320+
#else
1321+
return .ECANCELED
1322+
#endif
1323+
}
13261324

13271325
#if !os(Windows)
13281326
/// Identifier removed.

0 commit comments

Comments
 (0)