Created
April 19, 2019 04:32
-
-
Save colemancda/9f80ff08505d96821380c0b74622e58c to your computer and use it in GitHub Desktop.
Print all CocoaError messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| var errors = [CocoaError: String]() | |
| for code in 0 ... 4866 { | |
| let error = CocoaError(CocoaError.Code(rawValue: code)) | |
| if let reason = error._nsError.localizedFailureReason { | |
| errors[error] = reason | |
| } | |
| } | |
| print("private extension CocoaError {") | |
| print(" static let errorMessages = [") | |
| errors | |
| .sorted(by: { $0.key.code.rawValue < $1.key.code.rawValue }) | |
| .forEach { print(" Code(rawValue: \($0.key.code.rawValue)): \"\($0.value)\",") } | |
| print(" ]") | |
| print("}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used for swiftlang/swift-corelibs-foundation#2148