New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudKitOperation: Error Handling #167
Merged
danthorpe
merged 33 commits into
development
from
feature/OPR-167_cloud_kit_phase_4_error_handling
Jan 15, 2016
Merged
CloudKitOperation: Error Handling #167
danthorpe
merged 33 commits into
development
from
feature/OPR-167_cloud_kit_phase_4_error_handling
Jan 15, 2016
Conversation
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
danthorpe
changed the title
CloudKitOperation, phase 4: Error Handling
CloudKitOperation: Error Handling
Jan 13, 2016
4 tasks
So, the way the error handling will work is something like this, (or will be) // Fetch (all) Record Zones CloudKit Operation
let operation = CloudKitOperation { CKFetchRecordZonesOperation.fetchAllRecordZonesOperation() }
// Add custom error handlers
operation.setErrorHandlerForCode(.ConstraintViolation) { error, recommended in
// Inspect the error
// The recommended tuple is the "recommended" response. It might be .None.
// This is the result of the default error handlers being applied to the "next"
// delay & operation (using the generator provided at initialism).
// For errors such as this (a constraint violation) you'll typically want to log the
// info, and return .None (which is actually what the default error handler would do).
}
// Add error handlers for any CKErrorCode
operation.setErrorHandlerForCode(.PartialFailure) { error, recommended in
// etc
} |
Something weird is going on with the CloudKitOperation tests for sure.
Current coverage is
|
When GroupOperation is run inside another GroupOperation.
It's getting there.
Was missing a bit of coverage.
Okay, going to merge this now, and work on a CloudKit example in another branch. |
danthorpe
added a commit
that referenced
this pull request
Jan 15, 2016
…e_4_error_handling CloudKitOperation: Error Handling
danthorpe
deleted the
feature/OPR-167_cloud_kit_phase_4_error_handling
branch
January 16, 2016 11:20
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The 4th phase of CloudKitOperation refactoring.
CloudKitOperation
now subclassesRetryOperation
.addConfigurationBlock
concepts fromBatchedCloudKitOperation
.BatchedCloudKitOperation
should subclassRepeatedOperation
?Default Error Recovery
I think it would be great if the framework provided some convenient error handling for some of the more recoverable errors. Things like, not logged into iCloud for example. My thinking is a type
CloudKitErrorHandler
say, which can be used in conjunction withRetryOperation
as the "error recovery block".There are going to be some pretty standard error responses.
.None
(i.e. do not attempt to retry).InternalError
MissingEntitlement
InvalidArguments
ServerRejectedRequest
AssetFileNotFound
IncompatibleVersion
ConstraintViolation
BadDatabase
QuotaExceeded
OperationCancelled
NetworkUnavailable
NetworkFailure
ServiceUnavailable
RequestRateLimited
AssetFileModified
BatchRequestFailed
ZoneBusy
These will require a bit more thought:
PartialFailure
Some items failed, but the operation succeeded overall
Do not handle in anyway - should be handled by the framework consumer.
BadContainer
Un-provisioned or unauthorized container. Try provisioning the container before retrying the operation.
TODO: Look into what provisioning the container means.
Exit immediately - with fatal error logs, this is a compile time issue.
NotAuthenticated
Not authenticated (writing without being logged in, no user record)
PermissionFailure
Access failure (save or fetch)
This sounds like we could handle it automatically, with an Operation/Block which is an alert telling the user to log into iCloud. So, we don't retry, but we do add an
AlertPresentation
operation.UnknownItem
Record does not exist
ResultsTruncated
Query results were truncated by the server
Automatically adjust the parameters to fetch the next set of results?
ServerRecordChanged
The record was rejected because the version on the server was different
Automatically adjust the parameters and re-request?
ChangeTokenExpired
The previousServerChangeToken value is too old and the client must re-sync from scratch
Trigger a re-sync operation?
ZoneNotFound
The specified zone does not exist on the server
Add a new operation to create the Zone first, with dependencies setup.
LimitExceeded
The request to the server was too large. Retry this request as a smaller batch.
Automatically re-request as multiple batches?
UserDeletedZone
The user deleted this zone through the settings UI. Your client should either remove its local data or prompt the user before attempting to re-upload any data to this zone.
Retry with a UserConfirmationOperation?