Skip to content

Instantly share code, notes, and snippets.

@jazzychad
Created January 26, 2022 00:47
Show Gist options
  • Save jazzychad/fa175b4a2c7cab97762117130617f599 to your computer and use it in GitHub Desktop.
Save jazzychad/fa175b4a2c7cab97762117130617f599 to your computer and use it in GitHub Desktop.
Friendly strings for CKError.Code values
import CloudKit
extension CKError {
func stringForErrorCode() -> String {
let code = self.code
switch code {
case .internalError:
return "Internal error"
case .partialFailure:
return "Partial failure"
case .networkUnavailable:
return "Network unavailable"
case .networkFailure:
return "Network failure"
case .badContainer:
return "Bad container"
case .serviceUnavailable:
return "Service unavailable"
case .requestRateLimited:
return "Rate limited"
case .missingEntitlement:
return "Missing entitlement"
case .notAuthenticated:
return "Not authenticated"
case .permissionFailure:
return "Permission failure"
case .unknownItem:
return "Unknown item"
case .invalidArguments:
return "Invalid arguments"
case .resultsTruncated:
return "Results truncated"
case .serverRecordChanged:
return "Server record changed"
case .serverRejectedRequest:
return "Server rejected request"
case .assetFileNotFound:
return "Asset file not found"
case .assetFileModified:
return "Asset file modified"
case .incompatibleVersion:
return "Incompatible version"
case .constraintViolation:
return "Contstraint violation"
case .operationCancelled:
return "Operation cancelled"
case .changeTokenExpired:
return "Change token expired"
case .batchRequestFailed:
return "Batch request failed"
case .zoneBusy:
return "Zone busy"
case .badDatabase:
return "Bad database"
case .quotaExceeded:
return "Quota exceeded"
case .zoneNotFound:
return "Zone not found"
case .limitExceeded:
return "Limit exceeded"
case .userDeletedZone:
return "User deleted zone"
case .tooManyParticipants:
return "Too many participants"
case .alreadyShared:
return "Already shared"
case .referenceViolation:
return "Reference violation"
case .managedAccountRestricted:
return "Managed account restricted"
case .participantMayNeedVerification:
return "Participant may need verification"
case .serverResponseLost:
return "Server response lost"
case .assetNotAvailable:
return "Asset not available"
case .accountTemporarilyUnavailable:
return "Account temporarily unavailable"
@unknown default:
return "Unknown error"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment