I am running Swift 6.3 on WSL2 in Windows 11. The following behavior confuses me:
do {
let data = try Data(contentsOf: fileThatDoesNotExist)
} catch CocoaError.fileNoSuchFile {
// This is not hit since `fileNoSuchFile.rawValue == 4`
print(CocoaError.fileNoSuchFile)
} catch let error as CocoaError {
// This is hit and `error.code.rawValue == 260`
print(error)
} catch {
// N/A
}
Is this a known issue on Linux, or am I just doing something wrong? What is the cross-platform way to catch Cocoa errors?