This repository has been archived by the owner on Jun 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8804dcf
commit fbf1aeb
Showing
21 changed files
with
340 additions
and
89 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// CKOperationInfo.swift | ||
// OpenCloudKit | ||
// | ||
// Created by Ben Johnson on 29/07/2016. | ||
// | ||
// | ||
|
||
import Foundation | ||
|
||
class CKOperationInfo { | ||
|
||
} | ||
|
||
class CKDatabaseOperationInfo: CKOperationInfo { | ||
let databaseScope: CKDatabaseScope | ||
|
||
init(databaseScope: CKDatabaseScope) { | ||
self.databaseScope = databaseScope | ||
super.init() | ||
} | ||
|
||
} | ||
|
||
extension CKOperationInfo: CKCodable { | ||
var dictionary: [String : AnyObject] { | ||
return [:] | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// CKPrettyError.swift | ||
// OpenCloudKit | ||
// | ||
// Created by Ben Johnson on 29/07/2016. | ||
// | ||
// | ||
|
||
import Foundation | ||
|
||
enum CKError { | ||
case network(NSError) | ||
case server([String: AnyObject]) | ||
case parse(NSError) | ||
|
||
var error: NSError { | ||
switch self { | ||
case .network(let networkError): | ||
return ckError(forNetworkError: networkError) | ||
case .server(let dictionary): | ||
return ckError(forServerResponseDictionary: dictionary) | ||
case .parse(let parseError): | ||
return NSError(domain: CKErrorDomain, code: CKErrorCode.InternalError.rawValue, userInfo: parseError.userInfo) | ||
} | ||
} | ||
|
||
func ckError(forNetworkError networkError: NSError) -> NSError { | ||
let userInfo = networkError.userInfo | ||
let errorCode: CKErrorCode | ||
|
||
switch networkError.code { | ||
case NSURLErrorNotConnectedToInternet: | ||
errorCode = .NetworkUnavailable | ||
case NSURLErrorCannotFindHost, NSURLErrorCannotConnectToHost: | ||
errorCode = .ServiceUnavailable | ||
default: | ||
errorCode = .NetworkFailure | ||
} | ||
|
||
let error = NSError(domain: CKErrorDomain, code: errorCode.rawValue, userInfo: userInfo) | ||
return error | ||
} | ||
|
||
func ckError(forServerResponseDictionary dictionary: [String: AnyObject]) -> NSError { | ||
if let recordFetchError = CKRecordFetchErrorDictionary(dictionary: dictionary) { | ||
|
||
let errorCode = CKErrorCode.errorCode(serverError: recordFetchError.serverErrorCode)! | ||
|
||
var userInfo = [:] as NSErrorUserInfoType | ||
|
||
userInfo["redirectURL"] = recordFetchError.redirectURL | ||
userInfo[NSLocalizedDescriptionKey] = recordFetchError.reason | ||
|
||
userInfo[CKErrorRetryAfterKey] = recordFetchError.retryAfter | ||
userInfo["uuid"] = recordFetchError.uuid | ||
|
||
return NSError(domain: CKErrorDomain, code: errorCode.rawValue, userInfo: userInfo) | ||
|
||
} else { | ||
|
||
let userInfo = [:] as NSErrorUserInfoType | ||
return NSError(domain: CKErrorDomain, code: CKErrorCode.InternalError.rawValue, userInfo: userInfo) | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.