mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
Includes “Enable JIT” errors in Error Log
This commit is contained in:
@@ -692,6 +692,8 @@ extension AppManager
|
|||||||
var installedApp: InstalledApp?
|
var installedApp: InstalledApp?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let appName = installedApp.name
|
||||||
|
|
||||||
let context = Context()
|
let context = Context()
|
||||||
context.installedApp = installedApp
|
context.installedApp = installedApp
|
||||||
|
|
||||||
@@ -699,7 +701,16 @@ extension AppManager
|
|||||||
|
|
||||||
let enableJITOperation = EnableJITOperation(context: context)
|
let enableJITOperation = EnableJITOperation(context: context)
|
||||||
enableJITOperation.resultHandler = { (result) in
|
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)
|
enableJITOperation.addDependency(findServerOperation)
|
||||||
|
|
||||||
@@ -830,6 +841,19 @@ private extension AppManager
|
|||||||
|
|
||||||
return bundleIdentifier
|
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
|
func isActivelyManagingApp(withBundleID bundleID: String) -> Bool
|
||||||
@@ -1752,7 +1776,7 @@ private extension AppManager
|
|||||||
let error = nsError.withLocalizedTitle(localizedTitle)
|
let error = nsError.withLocalizedTitle(localizedTitle)
|
||||||
group.set(.failure(error), forAppWithBundleIdentifier: operation.bundleIdentifier)
|
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)
|
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.
|
// Sanitize NSError on same thread before performing background task.
|
||||||
let sanitizedError = (error as NSError).sanitizedForSerialization()
|
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
|
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
|
if let managedApp = app as? NSManagedObject, let tempApp = context.object(with: managedApp.objectID) as? AppProtocol
|
||||||
{
|
{
|
||||||
app = tempApp
|
app = tempApp
|
||||||
@@ -1804,7 +1815,7 @@ private extension AppManager
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_ = LoggedError(error: sanitizedError, app: app, operation: loggedErrorOperation, context: context)
|
_ = LoggedError(error: sanitizedError, app: app, operation: operation, context: context)
|
||||||
try context.save()
|
try context.save()
|
||||||
}
|
}
|
||||||
catch let saveError
|
catch let saveError
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ extension LoggedError
|
|||||||
case deactivate
|
case deactivate
|
||||||
case backup
|
case backup
|
||||||
case restore
|
case restore
|
||||||
|
case enableJIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ public extension LoggedError
|
|||||||
case .deactivate: return String(format: NSLocalizedString("Deactivate %@ Failed", comment: ""), self.appName)
|
case .deactivate: return String(format: NSLocalizedString("Deactivate %@ Failed", comment: ""), self.appName)
|
||||||
case .backup: return String(format: NSLocalizedString("Backup %@ 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 .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