Files
comaps/iphone/Maps/Core/iCloud/SynchronizationError.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

52 lines
2.1 KiB
Swift

@objc enum SynchronizationError: Int, Error {
case fileUnavailable
case fileNotUploadedDueToQuota
case ubiquityServerNotAvailable
case iCloudIsNotAvailable
case containerNotFound
case failedToOpenLocalDirectoryFileDescriptor
case failedToRetrieveLocalDirectoryContent
case failedToCreateMetadataItem
case failedToRetrieveMetadataQueryContent
}
extension SynchronizationError: LocalizedError {
var errorDescription: String? {
switch self {
case .fileUnavailable, .ubiquityServerNotAvailable:
return L("icloud_synchronization_error_connection_error")
case .fileNotUploadedDueToQuota:
return L("icloud_synchronization_error_quota_exceeded")
case .iCloudIsNotAvailable, .containerNotFound:
return L("icloud_synchronization_error_cloud_is_unavailable")
case .failedToOpenLocalDirectoryFileDescriptor:
return "Failed to open local directory file descriptor"
case .failedToRetrieveLocalDirectoryContent:
return "Failed to retrieve local directory content"
case .failedToCreateMetadataItem:
return "Failed to create metadata item."
case .failedToRetrieveMetadataQueryContent:
return "Failed to retrieve NSMetadataQuery content."
}
}
}
extension Error {
var ubiquitousError: SynchronizationError? {
let nsError = self as NSError
switch nsError.code {
// NSURLUbiquitousItemDownloadingErrorKey contains an error with this code when the item has not been uploaded to iCloud by the other devices yet
case NSUbiquitousFileUnavailableError:
return .fileUnavailable
// NSURLUbiquitousItemUploadingErrorKey contains an error with this code when the item has not been uploaded to iCloud because it would make the account go over-quota
case NSUbiquitousFileNotUploadedDueToQuotaError:
return .fileNotUploadedDueToQuota
// NSURLUbiquitousItemDownloadingErrorKey and NSURLUbiquitousItemUploadingErrorKey contain an error with this code when connecting to the iCloud servers failed
case NSUbiquitousFileUbiquityServerNotAvailable:
return .ubiquityServerNotAvailable
default:
return nil
}
}
}