mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Include "Enable JIT" errors in Error Log
This commit is contained in:
@@ -317,6 +317,31 @@ extension AppManager
|
|||||||
|
|
||||||
self.run([clearAppCacheOperation], context: nil)
|
self.run([clearAppCacheOperation], context: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func log(_ error: Error, operation: LoggedError.Operation, app: AppProtocol)
|
||||||
|
{
|
||||||
|
// Sanitize NSError on same thread before performing background task.
|
||||||
|
let sanitizedError = (error as NSError).sanitizedForSerialization()
|
||||||
|
|
||||||
|
DatabaseManager.shared.persistentContainer.performBackgroundTask { context in
|
||||||
|
var app = app
|
||||||
|
if let managedApp = app as? NSManagedObject, let tempApp = context.object(with: managedApp.objectID) as? AppProtocol
|
||||||
|
{
|
||||||
|
app = tempApp
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_ = LoggedError(error: sanitizedError, app: app, operation: operation, context: context)
|
||||||
|
try context.save()
|
||||||
|
}
|
||||||
|
catch let saveError
|
||||||
|
{
|
||||||
|
print("[ALTLog] Failed to log error \(sanitizedError.domain) code \(sanitizedError.code) for \(app.bundleIdentifier):", saveError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppManager
|
extension AppManager
|
||||||
@@ -680,13 +705,20 @@ extension AppManager
|
|||||||
var installedApp: InstalledApp?
|
var installedApp: InstalledApp?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let appName = installedApp.name
|
||||||
let context = Context()
|
let context = Context()
|
||||||
context.installedApp = installedApp
|
context.installedApp = installedApp
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.run([enableJITOperation], context: context, requiresSerialQueue: true)
|
self.run([enableJITOperation], context: context, requiresSerialQueue: true)
|
||||||
@@ -822,6 +854,18 @@ 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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@@ -1722,7 +1766,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1747,42 +1791,6 @@ private extension AppManager
|
|||||||
UNUserNotificationCenter.current().add(request)
|
UNUserNotificationCenter.current().add(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
func log(_ error: Error, for operation: AppOperation)
|
|
||||||
{
|
|
||||||
// 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
|
|
||||||
if let managedApp = app as? NSManagedObject, let tempApp = context.object(with: managedApp.objectID) as? AppProtocol
|
|
||||||
{
|
|
||||||
app = tempApp
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
_ = LoggedError(error: sanitizedError, app: app, operation: loggedErrorOperation, context: context)
|
|
||||||
try context.save()
|
|
||||||
}
|
|
||||||
catch let saveError
|
|
||||||
{
|
|
||||||
print("[ALTLog] Failed to log error \(sanitizedError.domain) code \(sanitizedError.code) for \(app.bundleIdentifier):", saveError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func run(_ operations: [Foundation.Operation], context: OperationContext?, requiresSerialQueue: Bool = false)
|
func run(_ operations: [Foundation.Operation], context: OperationContext?, requiresSerialQueue: Bool = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1352,11 +1352,13 @@ private extension MyAppsViewController
|
|||||||
{
|
{
|
||||||
if #available(iOS 17, *), !UserDefaults.standard.sidejitenable {
|
if #available(iOS 17, *), !UserDefaults.standard.sidejitenable {
|
||||||
let toastView = ToastView(error: OperationError.tooNewError)
|
let toastView = ToastView(error: OperationError.tooNewError)
|
||||||
|
AppManager.shared.log(OperationError.tooNewError, operation: .enableJIT, app: installedApp)
|
||||||
toastView.show(in: self)
|
toastView.show(in: self)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if #unavailable(iOS 17), !minimuxer.ready() {
|
if #unavailable(iOS 17), !minimuxer.ready() {
|
||||||
let toastView = ToastView(error: MinimuxerError.NoConnection)
|
let toastView = ToastView(error: MinimuxerError.NoConnection)
|
||||||
|
AppManager.shared.log(MinimuxerError.NoConnection, operation: .connection, app: installedApp)
|
||||||
toastView.show(in: self)
|
toastView.show(in: self)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ extension LoggedError
|
|||||||
case deactivate
|
case deactivate
|
||||||
case backup
|
case backup
|
||||||
case restore
|
case restore
|
||||||
|
case connection
|
||||||
|
case enableJIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +115,8 @@ 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 .connection: return String(format: NSLocalizedString("Connection during %@ Failed", comment: ""), self.appName)
|
||||||
|
case .enableJIT: return String(format: NSLocalizedString("Enabling JIT for %@ Failed", comment: ""), self.appName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user