mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Move User Defaults errors to ErrorConstants file
This commit is contained in:
parent
223ebf5b7c
commit
dfb3a08608
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user