Move User Defaults errors to ErrorConstants file

This commit is contained in:
Angelo Stavrow 2022-05-13 08:44:13 -04:00
parent 223ebf5b7c
commit dfb3a08608
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 16 additions and 12 deletions

View File

@ -81,6 +81,21 @@ extension AccountError: LocalizedError {
}
}
// MARK: - User Defaults Errors
enum UserDefaultsError: Error {
case couldNotMigrateStandardDefaults
}
extension UserDefaultsError: LocalizedError {
public var errorDescription: String? {
switch self {
case .couldNotMigrateStandardDefaults:
return NSLocalizedString("Could not migrate user defaults to group container", comment: "")
}
}
}
// MARK: - Local Store Errors
enum LocalStoreError: Error {

View File

@ -17,17 +17,6 @@ enum WFDefaults {
extension UserDefaults {
private enum DefaultsError: Error {
case couldNotMigrateStandardDefaults
var description: String {
switch self {
case .couldNotMigrateStandardDefaults:
return "Could not migrate user defaults to group container."
}
}
}
private static let appGroupName: String = "group.com.abunchtell.writefreely"
private static let didMigrateDefaultsToAppGroup: String = "didMigrateDefaultsToAppGroup"
private static let didRemoveStandardDefaults: String = "didRemoveStandardDefaults"
@ -61,7 +50,7 @@ extension UserDefaults {
groupDefaults.set(true, forKey: UserDefaults.didMigrateDefaultsToAppGroup)
return groupDefaults
} else {
throw DefaultsError.couldNotMigrateStandardDefaults
throw UserDefaultsError.couldNotMigrateStandardDefaults
}
}