-
-
Save mergesort/4d0184fb6ac9d803f8be 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
protocol APIError { | |
var domain: String { get } | |
var code: ErrorCode { get } | |
} | |
struct UnexpectedAPIError : APIError { | |
let domain = "An unexpected error occurred" | |
let code = ErrorCode.UnexpectedAPIError | |
} | |
extension NSError { | |
class func APIError<T: APIError>(error: T) -> NSError { | |
return NSError(domain: error.domain, code: error.code.rawValue, userInfo: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment