From dfb3a08608ed8ec2e2e62ad3010c9d2a67691e51 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 13 May 2022 08:44:13 -0400 Subject: [PATCH] Move User Defaults errors to ErrorConstants file --- Shared/ErrorHandling/ErrorConstants.swift | 15 +++++++++++++++ Shared/Extensions/UserDefaults+Extensions.swift | 13 +------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Shared/ErrorHandling/ErrorConstants.swift b/Shared/ErrorHandling/ErrorConstants.swift index 2962246..676f299 100644 --- a/Shared/ErrorHandling/ErrorConstants.swift +++ b/Shared/ErrorHandling/ErrorConstants.swift @@ -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 { diff --git a/Shared/Extensions/UserDefaults+Extensions.swift b/Shared/Extensions/UserDefaults+Extensions.swift index f40a824..b010fdc 100644 --- a/Shared/Extensions/UserDefaults+Extensions.swift +++ b/Shared/Extensions/UserDefaults+Extensions.swift @@ -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 } }