]> git.saurik.com Git - apple/security.git/blob - keychain/TrustedPeersHelper/CuttlefishErrors.swift
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / TrustedPeersHelper / CuttlefishErrors.swift
1 import Foundation
2
3 struct CuttlefishErrorMatcher {
4 let code: CuttlefishErrorCode
5 }
6
7 // Use a 'pattern match operator' to make pretty case statements matching Cuttlefish errors
8 func ~= (pattern: CuttlefishErrorMatcher, value: Error?) -> Bool {
9 guard let error = value else {
10 return false
11 }
12 let nserror = error as NSError
13 return nserror.isCuttlefishError(pattern.code)
14 }
15
16 func CuttlefishRetryAfter(error: Error?) -> TimeInterval {
17 guard let error = error else {
18 return 0
19 }
20 let nserror = error as NSError
21 return nserror.cuttlefishRetryAfter()
22 }