Created
March 25, 2020 13:19
-
-
Save bocato/0f62dca70f6a513ce11175e9dbc25f82 to your computer and use it in GitHub Desktop.
This file contains 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
extension NSError { | |
/// A convenience initializer for NSError to set its description. | |
/// | |
/// - Parameters: | |
/// - domain: The error domain. | |
/// - code: The error code. | |
/// - description: Some description for this error. | |
convenience init(domain: String, code: Int, description: String) { | |
self.init(domain: domain, code: code, userInfo: [(kCFErrorLocalizedDescriptionKey as CFString) as String: description]) | |
} | |
} | |
// Usage | |
let myError = NSError( | |
domain: "SomeDomain", | |
code: 123, | |
description: "Some description." | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment