Includes “Enable JIT” errors in Error Log

This commit is contained in:
Riley Testut
2023-01-24 14:07:30 -06:00
committed by Magesh K
parent b458e75098
commit 95a3bbf6b9

View File

@@ -704,7 +704,6 @@ extension AppManager
var installedApp: InstalledApp? var installedApp: InstalledApp?
} }
let appName = installedApp.name
let context = Context() let context = Context()
context.installedApp = installedApp context.installedApp = installedApp
@@ -714,11 +713,14 @@ extension AppManager
switch result { switch result {
case .success: completionHandler(.success(())) case .success: completionHandler(.success(()))
case .failure(let nsError as NSError): case .failure(let nsError as NSError):
let localizedTitle = String(format: NSLocalizedString("Failed to enable JIT for %@", comment: ""), appName) let localizedTitle = String(format: NSLocalizedString("Failed to Enable JIT for %@", comment: ""), appName)
let error = nsError.withLocalizedTitle(localizedTitle) let error = nsError.withLocalizedTitle(localizedTitle)
self.log(error, operation: .enableJIT, app: installedApp) self.log(error, operation: .enableJIT, app: installedApp)
completionHandler(.failure(error))
} }
} }
enableJITOperation.addDependency(findServerOperation)
self.run([enableJITOperation], context: context, requiresSerialQueue: true) self.run([enableJITOperation], context: context, requiresSerialQueue: true)
} }
@@ -1999,7 +2001,7 @@ 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()
@@ -2016,9 +2018,9 @@ private extension AppManager
case .restore: return .restore 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
@@ -2026,7 +2028,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