mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 23:03:27 +01:00
Includes “Enable JIT” errors in Error Log
This commit is contained in:
@@ -692,6 +692,8 @@ extension AppManager
|
||||
var installedApp: InstalledApp?
|
||||
}
|
||||
|
||||
let appName = installedApp.name
|
||||
|
||||
let context = Context()
|
||||
context.installedApp = installedApp
|
||||
|
||||
@@ -699,7 +701,16 @@ extension AppManager
|
||||
|
||||
let enableJITOperation = EnableJITOperation(context: context)
|
||||
enableJITOperation.resultHandler = { (result) in
|
||||
completionHandler(result)
|
||||
switch result
|
||||
{
|
||||
case .success: completionHandler(.success(()))
|
||||
case .failure(let nsError as NSError):
|
||||
let localizedTitle = String(format: NSLocalizedString("Failed to Enable JIT for %@", comment: ""), appName)
|
||||
let error = nsError.withLocalizedTitle(localizedTitle)
|
||||
|
||||
self.log(error, operation: .enableJIT, app: installedApp)
|
||||
completionHandler(.failure(error))
|
||||
}
|
||||
}
|
||||
enableJITOperation.addDependency(findServerOperation)
|
||||
|
||||
@@ -830,6 +841,19 @@ private extension AppManager
|
||||
|
||||
return bundleIdentifier
|
||||
}
|
||||
|
||||
var loggedErrorOperation: LoggedError.Operation {
|
||||
switch self
|
||||
{
|
||||
case .install: return .install
|
||||
case .update: return .update
|
||||
case .refresh: return .refresh
|
||||
case .activate: return .activate
|
||||
case .deactivate: return .deactivate
|
||||
case .backup: return .backup
|
||||
case .restore: return .restore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isActivelyManagingApp(withBundleID bundleID: String) -> Bool
|
||||
@@ -1752,7 +1776,7 @@ private extension AppManager
|
||||
let error = nsError.withLocalizedTitle(localizedTitle)
|
||||
group.set(.failure(error), forAppWithBundleIdentifier: operation.bundleIdentifier)
|
||||
|
||||
self.log(error, for: operation)
|
||||
self.log(error, operation: operation.loggedErrorOperation, app: operation.app)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1777,26 +1801,13 @@ private extension AppManager
|
||||
UNUserNotificationCenter.current().add(request)
|
||||
}
|
||||
|
||||
func log(_ error: Error, for operation: AppOperation)
|
||||
func log(_ error: Error, operation: LoggedError.Operation, app: AppProtocol)
|
||||
{
|
||||
// Sanitize NSError on same thread before performing background task.
|
||||
let sanitizedError = (error as NSError).sanitizedForSerialization()
|
||||
|
||||
let loggedErrorOperation: LoggedError.Operation = {
|
||||
switch operation
|
||||
{
|
||||
case .install: return .install
|
||||
case .update: return .update
|
||||
case .refresh: return .refresh
|
||||
case .activate: return .activate
|
||||
case .deactivate: return .deactivate
|
||||
case .backup: return .backup
|
||||
case .restore: return .restore
|
||||
}
|
||||
}()
|
||||
|
||||
DatabaseManager.shared.persistentContainer.performBackgroundTask { context in
|
||||
var app = operation.app
|
||||
var app = app
|
||||
if let managedApp = app as? NSManagedObject, let tempApp = context.object(with: managedApp.objectID) as? AppProtocol
|
||||
{
|
||||
app = tempApp
|
||||
@@ -1804,7 +1815,7 @@ private extension AppManager
|
||||
|
||||
do
|
||||
{
|
||||
_ = LoggedError(error: sanitizedError, app: app, operation: loggedErrorOperation, context: context)
|
||||
_ = LoggedError(error: sanitizedError, app: app, operation: operation, context: context)
|
||||
try context.save()
|
||||
}
|
||||
catch let saveError
|
||||
|
||||
@@ -19,6 +19,7 @@ extension LoggedError
|
||||
case deactivate
|
||||
case backup
|
||||
case restore
|
||||
case enableJIT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +114,7 @@ public extension LoggedError
|
||||
case .deactivate: return String(format: NSLocalizedString("Deactivate %@ Failed", comment: ""), self.appName)
|
||||
case .backup: return String(format: NSLocalizedString("Backup %@ Failed", comment: ""), self.appName)
|
||||
case .restore: return String(format: NSLocalizedString("Restore %@ Failed", comment: ""), self.appName)
|
||||
case .enableJIT: return String(format: NSLocalizedString("Enable JIT for %@ Failed", comment: ""), self.appName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user