Skip to content

Commit

Permalink
add user facing error for errors occurring when fetching status/settings
Browse files Browse the repository at this point in the history
bump version
  • Loading branch information
lukepistrol committed Nov 15, 2023
1 parent 6deb4a7 commit 6116248
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
16 changes: 8 additions & 8 deletions TimeMachineStatus.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@
CODE_SIGN_ENTITLEMENTS = TimeMachineStatusHelper/TimeMachineStatusHelper.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 4;
ENABLE_HARDENED_RUNTIME = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
Expand All @@ -538,7 +538,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.0.3;
MARKETING_VERSION = 0.0.4;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaspistrol.TimeMachineStatusHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -554,8 +554,8 @@
CODE_SIGN_ENTITLEMENTS = TimeMachineStatusHelper/TimeMachineStatusHelper.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 4;
ENABLE_HARDENED_RUNTIME = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
Expand All @@ -567,7 +567,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.0.3;
MARKETING_VERSION = 0.0.4;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaspistrol.TimeMachineStatusHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -702,7 +702,7 @@
CODE_SIGN_ENTITLEMENTS = TimeMachineStatus/TimeMachineStatus.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"TimeMachineStatus/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
Expand All @@ -719,7 +719,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.0.3;
MARKETING_VERSION = 0.0.4;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaspistrol.TimeMachineStatus;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -736,7 +736,7 @@
CODE_SIGN_ENTITLEMENTS = TimeMachineStatus/TimeMachineStatus.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"TimeMachineStatus/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
Expand All @@ -753,7 +753,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.0.3;
MARKETING_VERSION = 0.0.4;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaspistrol.TimeMachineStatus;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
6 changes: 6 additions & 0 deletions TimeMachineStatus/Error/UserfacingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ import SwiftUI

enum UserfacingError: Error {
case fullDiskPermissionDenied
case debugError(error: Error)

var title: LocalizedStringKey {
switch self {
case .fullDiskPermissionDenied:
return "error_fulldiskpermissiondenied_title"
case .debugError:
return "error_debug_title"
}
}

var failureReason: LocalizedStringKey? {
switch self {
case .fullDiskPermissionDenied:
return "error_fulldiskpermissiondenied_description"
case .debugError(let error):
return "error_debug_description\(error.localizedDescription)"
}
}

Expand All @@ -35,6 +40,7 @@ enum UserfacingError: Error {
title: "button_opensystemsettings",
url: Constants.URLs.settingsFullDiskAccess
)
default: nil
}
}

Expand Down
32 changes: 32 additions & 0 deletions TimeMachineStatus/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,38 @@
}
}
},
"error_debug_description%@" : {
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Error Description: %@"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Error Description: %@"
}
}
}
},
"error_debug_title" : {
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unknown Error"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unknown Error"
}
}
}
},
"error_fulldiskpermissiondenied_description" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
3 changes: 3 additions & 0 deletions TimeMachineStatus/ViewModel/TMUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TMUtility: ObservableObject {
start(force: status is BackupState.None)
} catch {
log.error("Error updating status: \(error)")
self.error = UserfacingError.debugError(error: error)
start(force: true)
}
}
Expand All @@ -63,6 +64,8 @@ class TMUtility: ObservableObject {
log.error("Error reading preferences: \(error)")
if (error as NSError).code == 257 {
self.error = UserfacingError.fullDiskPermissionDenied
} else {
self.error = UserfacingError.debugError(error: error)
}
}
}
Expand Down

0 comments on commit 6116248

Please sign in to comment.