mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
* Change error from Swift.Error to NSError
* Adds ResultOperation.localizedFailure
* Finish Riley's monster commit
3b38d725d7
May the Gods have mercy on my soul.
* Fix format strings I broke
* Include "Enable JIT" errors in Error Log
* Fix minimuxer status checking
* [skip ci] Update the no wifi message to include VPN
* Opens Error Log when tapping ToastView
* Fixes Error Log context menu covering cell content
* Fixes Error Log context menu appearing while scrolling
* Fixes incorrect Search FAQ URL
* Fix Error Log showing UIAlertController on iOS 14+
* Fix Error Log not showing UIAlertController on iOS <=13
* Fix wrong color in AuthenticationViewController
* Fix typo
* Fixes logging non-AltServerErrors as AltServerError.underlyingError
* Limits quitting other AltStore/SideStore processes to database migrations
* Skips logging cancelled errors
* Replaces StoreApp.latestVersion with latestSupportedVersion + latestAvailableVersion
We now store the latest supported version as a relationship on StoreApp, rather than the latest available version. This allows us to reference the latest supported version in predicates and sort descriptors.
However, we kept the underlying Core Data property name the same to avoid extra migration.
* Conforms OperatingSystemVersion to Comparable
* Parses AppVersion.minOSVersion/maxOSVersion from source JSON
* Supports non-NSManagedObjects for @Managed properties
This allows us to use @Managed with properties that may or may not be NSManagedObjects at runtime (e.g. protocols). If they are, Managed will keep strong reference to context like before.
* Supports optional @Managed properties
* Conforms AppVersion to AppProtocol
* Verifies min/max OS version before downloading app + asks user to download older app version if necessary
* Improves error message when file does not exist at AppVersion.downloadURL
* Removes unnecessary StoreApp convenience properties
* Removes unnecessary StoreApp convenience properties as well as fix other issues
* Remove Settings bundle, add SwiftUI view instead
Fix refresh all shortcut intent
* Update AuthenticationOperation.swift
Signed-off-by: June Park <rjp2030@outlook.com>
* Fix build issues given by develop
* Add availability check to fix CI build(?)
* If it's gonna be that way...
---------
Signed-off-by: June Park <rjp2030@outlook.com>
Co-authored-by: nythepegasus <nythepegasus84@gmail.com>
Co-authored-by: Riley Testut <riley@rileytestut.com>
Co-authored-by: ny <me@nythepegas.us>
136 lines
4.6 KiB
Swift
136 lines
4.6 KiB
Swift
//
|
|
// LoggedError.swift
|
|
// AltStoreCore
|
|
//
|
|
// Created by Riley Testut on 9/6/22.
|
|
// Copyright © 2022 Riley Testut. All rights reserved.
|
|
//
|
|
|
|
import CoreData
|
|
|
|
extension LoggedError
|
|
{
|
|
public enum Operation: String
|
|
{
|
|
case install
|
|
case update
|
|
case refresh
|
|
case activate
|
|
case deactivate
|
|
case backup
|
|
case restore
|
|
case connection
|
|
case enableJIT
|
|
}
|
|
}
|
|
|
|
@objc(LoggedError)
|
|
public class LoggedError: NSManagedObject, Fetchable
|
|
{
|
|
/* Properties */
|
|
@NSManaged public private(set) var date: Date
|
|
|
|
@nonobjc public var operation: Operation? {
|
|
guard let rawOperation = self._operation else { return nil }
|
|
|
|
let operation = Operation(rawValue: rawOperation)
|
|
return operation
|
|
}
|
|
@NSManaged @objc(operation) private var _operation: String?
|
|
|
|
@NSManaged public private(set) var domain: String
|
|
@NSManaged public private(set) var code: Int32
|
|
@NSManaged public private(set) var userInfo: [String: Any]
|
|
|
|
@NSManaged public private(set) var appName: String
|
|
@NSManaged public private(set) var appBundleID: String
|
|
|
|
/* Relationships */
|
|
@NSManaged public private(set) var storeApp: StoreApp?
|
|
@NSManaged public private(set) var installedApp: InstalledApp?
|
|
|
|
private static let dateFormatter: DateFormatter = {
|
|
let dateFormatter = DateFormatter()
|
|
dateFormatter.dateStyle = .long
|
|
dateFormatter.timeStyle = .none
|
|
return dateFormatter
|
|
}()
|
|
|
|
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
|
{
|
|
super.init(entity: entity, insertInto: context)
|
|
}
|
|
|
|
public init(error: Error, app: AppProtocol, date: Date = Date(), operation: Operation? = nil, context: NSManagedObjectContext)
|
|
{
|
|
super.init(entity: LoggedError.entity(), insertInto: context)
|
|
|
|
self.date = date
|
|
self._operation = operation?.rawValue
|
|
|
|
let nsError: NSError
|
|
if let error = error as? ALTServerError, error.code == .underlyingError, let underlyingError = error.underlyingError {
|
|
nsError = underlyingError as NSError
|
|
} else {
|
|
nsError = error as NSError
|
|
}
|
|
self.domain = nsError.domain
|
|
self.code = Int32(nsError.code)
|
|
self.userInfo = nsError.userInfo
|
|
|
|
self.appName = app.name
|
|
self.appBundleID = app.bundleIdentifier
|
|
|
|
switch app
|
|
{
|
|
case let storeApp as StoreApp: self.storeApp = storeApp
|
|
case let installedApp as InstalledApp: self.installedApp = installedApp
|
|
default: break
|
|
}
|
|
}
|
|
}
|
|
|
|
public extension LoggedError
|
|
{
|
|
var app: AppProtocol {
|
|
// `as AppProtocol` needed to fix "cannot convert AnyApp to StoreApp" compiler error with Xcode 14.
|
|
let app = self.installedApp ?? self.storeApp ?? AnyApp(name: self.appName, bundleIdentifier: self.appBundleID, url: nil) as AppProtocol
|
|
return app
|
|
}
|
|
|
|
var error: NSError {
|
|
let nsError = NSError(domain: self.domain, code: Int(self.code), userInfo: self.userInfo)
|
|
return nsError
|
|
}
|
|
|
|
@objc
|
|
var localizedDateString: String {
|
|
let localizedDateString = LoggedError.dateFormatter.string(from: self.date)
|
|
return localizedDateString
|
|
}
|
|
|
|
var localizedFailure: String? {
|
|
guard let operation = self.operation else { return nil }
|
|
switch operation
|
|
{
|
|
case .install: return String(format: NSLocalizedString("Install %@ Failed", comment: ""), self.appName)
|
|
case .update: return String(format: NSLocalizedString("Update %@ Failed", comment: ""), self.appName)
|
|
case .refresh: return String(format: NSLocalizedString("Refresh %@ Failed", comment: ""), self.appName)
|
|
case .activate: return String(format: NSLocalizedString("Activate %@ 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 .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)
|
|
}
|
|
}
|
|
}
|
|
|
|
public extension LoggedError
|
|
{
|
|
@nonobjc class func fetchRequest() -> NSFetchRequest<LoggedError>
|
|
{
|
|
return NSFetchRequest<LoggedError>(entityName: "LoggedError")
|
|
}
|
|
}
|