mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltServer] Improves ALTServerErrorIncompatibleDeveloperDisk error message
Uses NSError’s debug description, if available, to populate error alerts.
This commit is contained in:
@@ -319,7 +319,12 @@ private extension AppDelegate
|
|||||||
|
|
||||||
if let errorFailure = nsError.localizedFailure
|
if let errorFailure = nsError.localizedFailure
|
||||||
{
|
{
|
||||||
if let failureReason = nsError.localizedFailureReason
|
if let debugDescription = nsError.localizedDebugDescription
|
||||||
|
{
|
||||||
|
alert.messageText = errorFailure
|
||||||
|
messageComponents.append(debugDescription)
|
||||||
|
}
|
||||||
|
else if let failureReason = nsError.localizedFailureReason
|
||||||
{
|
{
|
||||||
if nsError.localizedDescription.starts(with: errorFailure)
|
if nsError.localizedDescription.starts(with: errorFailure)
|
||||||
{
|
{
|
||||||
@@ -352,7 +357,15 @@ private extension AppDelegate
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
alert.messageText = localizedFailure
|
alert.messageText = localizedFailure
|
||||||
messageComponents.append(nsError.localizedDescription)
|
|
||||||
|
if let debugDescription = nsError.localizedDebugDescription
|
||||||
|
{
|
||||||
|
messageComponents.append(debugDescription)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
messageComponents.append(nsError.localizedDescription)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let recoverySuggestion = nsError.localizedRecoverySuggestion
|
if let recoverySuggestion = nsError.localizedRecoverySuggestion
|
||||||
|
|||||||
@@ -1219,6 +1219,7 @@ NSNotificationName const ALTDeviceManagerDeviceDidDisconnectNotification = @"ALT
|
|||||||
// Connection failed with .unknown error code, so we assume the developer disk is NOT compatible.
|
// Connection failed with .unknown error code, so we assume the developer disk is NOT compatible.
|
||||||
NSMutableDictionary *userInfo = [@{
|
NSMutableDictionary *userInfo = [@{
|
||||||
ALTOperatingSystemVersionErrorKey: NSStringFromOperatingSystemVersion(altDevice.osVersion),
|
ALTOperatingSystemVersionErrorKey: NSStringFromOperatingSystemVersion(altDevice.osVersion),
|
||||||
|
NSFilePathErrorKey: diskURL.path,
|
||||||
NSUnderlyingErrorKey: error,
|
NSUnderlyingErrorKey: error,
|
||||||
} mutableCopy];
|
} mutableCopy];
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey = @"ALTOperatingSyste
|
|||||||
{
|
{
|
||||||
return [error altserver_localizedRecoverySuggestion];
|
return [error altserver_localizedRecoverySuggestion];
|
||||||
}
|
}
|
||||||
|
else if ([userInfoKey isEqualToString:NSDebugDescriptionErrorKey])
|
||||||
|
{
|
||||||
|
return [error altserver_localizedDebugDescription];
|
||||||
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}];
|
}];
|
||||||
@@ -172,6 +176,28 @@ NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey = @"ALTOperatingSyste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (nullable NSString *)altserver_localizedDebugDescription
|
||||||
|
{
|
||||||
|
switch ((ALTServerError)self.code)
|
||||||
|
{
|
||||||
|
case ALTServerErrorIncompatibleDeveloperDisk:
|
||||||
|
{
|
||||||
|
NSString *path = self.userInfo[NSFilePathErrorKey];
|
||||||
|
if (path == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *osVersion = [self altserver_osVersion] ?: NSLocalizedString(@"this device's OS version", @"");
|
||||||
|
NSString *debugDescription = [NSString stringWithFormat:NSLocalizedString(@"The Developer disk located at\n\n%@\n\nis incompatible with %@.", @""), path, osVersion];
|
||||||
|
return debugDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *)profileErrorLocalizedDescriptionWithBaseDescription:(NSString *)baseDescription
|
- (NSString *)profileErrorLocalizedDescriptionWithBaseDescription:(NSString *)baseDescription
|
||||||
{
|
{
|
||||||
NSString *localizedDescription = nil;
|
NSString *localizedDescription = nil;
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ extension NSError
|
|||||||
return localizedFailure
|
return localizedFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc(alt_localizedDebugDescription)
|
||||||
|
var localizedDebugDescription: String? {
|
||||||
|
let debugDescription = (self.userInfo[NSDebugDescriptionErrorKey] as? String) ?? (NSError.userInfoValueProvider(forDomain: self.domain)?(self, NSDebugDescriptionErrorKey) as? String)
|
||||||
|
return debugDescription
|
||||||
|
}
|
||||||
|
|
||||||
@objc(alt_errorWithLocalizedFailure:)
|
@objc(alt_errorWithLocalizedFailure:)
|
||||||
func withLocalizedFailure(_ failure: String) -> NSError
|
func withLocalizedFailure(_ failure: String) -> NSError
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user