Created
February 1, 2018 07:46
-
-
Save Anatoli-Petrosyants/4576e8a56f1a6084cbd8e66961334c7c 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
public extension NSError { | |
public class var emptyErrorDomain: String { return "com.ap.error.default" } | |
public class var emptyErrorCode: Int { return 1024 } | |
public class var empty: NSError { | |
return NSError(domain: emptyErrorDomain, code: emptyErrorCode, userInfo: nil) | |
} | |
public class func make(message: String, code: Int = 9999) -> NSError { | |
return NSError( | |
domain: "com.ap.error.maker", | |
code: code, | |
userInfo: [NSLocalizedDescriptionKey: message, NSLocalizedFailureReasonErrorKey: message] | |
) | |
} | |
} | |
public func NSErrorFrom(message: String, code: Int = 9999) -> NSError { | |
return NSError.make(message: message, code: code) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment