mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-17 10:43:30 +01:00
refactor: Reduce duplicate code with Error.message()
also add some things I forgot in previous commits
This commit is contained in:
13
AltStore/Extensions/Error+Message.swift
Normal file
13
AltStore/Extensions/Error+Message.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Error+Message.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by naturecodevoid on 5/30/23.
|
||||
// Copyright © 2023 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
extension Error {
|
||||
func message() -> String {
|
||||
(self as? LocalizedError)?.failureReason ?? self.localizedDescription
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg
|
||||
try start(pairing_file, documentsDirectory)
|
||||
} catch {
|
||||
try! FileManager.default.removeItem(at: FileManager.default.documentsDirectory.appendingPathComponent("\(pairingFileName)"))
|
||||
displayError("minimuxer failed to start, please restart SideStore. \((error as? LocalizedError)?.failureReason ?? "UNKNOWN ERROR!!!!!! REPORT TO GITHUB ISSUES!")")
|
||||
displayError("minimuxer failed to start, please restart SideStore. \(error.message())")
|
||||
}
|
||||
set_debug(UserDefaults.shared.isDebugLoggingEnabled)
|
||||
start_auto_mounter(documentsDirectory)
|
||||
|
||||
@@ -191,12 +191,6 @@ You should only enable Developer Mode if you meet one of the following requireme
|
||||
"DevModeView.password" = "Password";
|
||||
"DevModeView.incorrectPassword" = "Incorrect password.";
|
||||
"DevModeView.read" = "Read the text!";
|
||||
"DevModeView.console" = "Console";
|
||||
"DevModeView.dataExplorer" = "Data File Explorer";
|
||||
"DevModeView.tmpExplorer" = "Temporary File Explorer";
|
||||
"DevModeView.skipResign" = "Skip Resign";
|
||||
"DevModeView.footer" = "Skip Resign should only be used when you have an IPA that you have self signed. Otherwise, it will break things, and might make SideStore crash (there is absolutely no error handling and everything is expected to work).";
|
||||
"DevModeView.minimuxer" = "minimuxer debug actions";
|
||||
"DevModeView.General.header" = "General";
|
||||
"DevModeView.General.console" = "Console";
|
||||
"DevModeView.General.unstableFeaturesNightlyOnly" = "Unstable Features are only available on nightly builds, PR builds and debug builds.";
|
||||
|
||||
@@ -140,26 +140,26 @@ private extension SceneDelegate
|
||||
}
|
||||
|
||||
case "sidejit-enable":
|
||||
guard UnstableFeatures.enabled(.jitUrlScheme) else { return UIApplication.alertOk(title: "JIT URL scheme unstable feature is not enabled", message: nil) }
|
||||
guard UnstableFeatures.enabled(.jitUrlScheme) else { return UIApplication.alert(title: "JIT URL scheme unstable feature is not enabled", message: nil) }
|
||||
|
||||
if let bundleID = queryItems["bid"] {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
try debug_app(bundleID)
|
||||
} catch {
|
||||
UIApplication.alertOk(title: "An error occurred when enabling JIT", message: error.localizedDescription)
|
||||
UIApplication.alert(title: "An error occurred when enabling JIT", message: error.message())
|
||||
}
|
||||
}
|
||||
} else if let processID = queryItems["pid"] {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
guard let processID = UInt32(processID) else { return UIApplication.alertOk(title: "An error occurred when enabling JIT", message: "Process ID is not a valid unsigned integer") }
|
||||
guard let processID = UInt32(processID) else { return UIApplication.alert(title: "An error occurred when enabling JIT", message: "Process ID is not a valid unsigned integer") }
|
||||
try attach_debugger(processID)
|
||||
} catch {
|
||||
UIApplication.alertOk(title: "An error occurred when enabling JIT", message: error.localizedDescription)
|
||||
UIApplication.alert(title: "An error occurred when enabling JIT", message: error.message())
|
||||
}
|
||||
}
|
||||
} else { return UIApplication.alertOk(title: "An error occurred when enabling JIT", message: "Please specify a bundle ID using the `bid` query parameter or a process ID using `pid` query parameter") }
|
||||
} else { return UIApplication.alert(title: "An error occurred when enabling JIT", message: "Please specify a bundle ID using the `bid` query parameter or a process ID using `pid` query parameter") }
|
||||
|
||||
default: break
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ struct AsyncFallibleButton<Label: View>: View {
|
||||
} catch {
|
||||
DispatchQueue.main.async {
|
||||
state = .error
|
||||
errorAlertMessage = (error as? LocalizedError)?.failureReason ?? error.localizedDescription
|
||||
errorAlertMessage = error.message()
|
||||
showErrorAlert = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ extension OnboardingView {
|
||||
try! FileManager.default.removeItem(at: FileManager.default.documentsDirectory.appendingPathComponent("\(pairingFileName)"))
|
||||
NotificationManager.shared.reportError(error: error)
|
||||
debugPrint("minimuxer failed to start, please restart SideStore.", error)
|
||||
// displayError("minimuxer failed to start, please restart SideStore. \((error as? LocalizedError)?.failureReason ?? "UNKNOWN ERROR!!!!!! REPORT TO GITHUB ISSUES!")")
|
||||
// displayError("minimuxer failed to start, please restart SideStore. \(error.message())")
|
||||
}
|
||||
start_auto_mounter(documentsDirectory)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user