mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Remove most production-reachable instances of abort().
This commit is contained in:
1 parent
a045f1a50b
commit
e5e4c6c2e1
8 files changed
+46
-21
No files matched your search
Vendored
-2
@@ -69,14 +69,12 @@
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeInstallingUpdateWithCompletion: called on SPUAutomaticUpdateDriver");
|
||||
abort();
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)__unused resumableUpdate completion:(SPUUpdateDriverCompletion)__unused completionBlock __attribute__((noreturn))
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeDownloadedUpdate:completion: called on SPUAutomaticUpdateDriver");
|
||||
abort();
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem
|
||||
|
||||
+9
-1
@@ -73,7 +73,15 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
SULog(SULogLevelError, @"Fatal updater error (%ld): %@", updaterError.code, updaterError.localizedDescription);
|
||||
abort();
|
||||
|
||||
// Delay the alert four seconds so it doesn't show RIGHT as the app launches, but also doesn't interrupt the user once they really get to work.
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"Unable to Check For Updates";
|
||||
alert.informativeText = @"The update checker failed to start correctly. You should contact the app developer to report this issue and verify that you have the latest version.";
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert runModal];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -134,9 +134,9 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
If the updater's delegate implements -[SPUUpdaterDelegate feedURLStringForUpdater:], this will return that feed URL.
|
||||
Otherwise if the feed URL has been set before, the feed URL returned will be retrieved from the host bundle's user defaults.
|
||||
Otherwise the feed URL in the host bundle's Info.plist will be returned.
|
||||
If no feed URL can be retrieved, this will raise an exception.
|
||||
If no feed URL can be retrieved, returns nil.
|
||||
|
||||
This property must be called on the main thread.
|
||||
This property must be called on the main thread; calls from background threads will return nil.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSURL *feedURL;
|
||||
|
||||
@@ -149,7 +149,7 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
Passing nil will remove any feed URL that has been set in the host bundle's user defaults.
|
||||
|
||||
This method must be called on the main thread.
|
||||
This method must be called on the main thread; calls from background threads will have no effect.
|
||||
*/
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL;
|
||||
|
||||
|
||||
Vendored
+22
-11
@@ -115,16 +115,24 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
// To prevent subclasses from doing something bad based on older Sparkle code
|
||||
- (instancetype)initForBundle:(NSBundle *)__unused bundle
|
||||
{
|
||||
SULog(SULogLevelError, @"-[%@ initForBundle:] is not implemented anymore.", NSStringFromClass([self class]));
|
||||
abort();
|
||||
NSString *reason = [NSString stringWithFormat:@"-[%@ initForBundle:] is not implemented anymore in Sparkle 2.", NSStringFromClass([self class])];
|
||||
SULog(SULogLevelError, reason);
|
||||
|
||||
NSException *exception = [NSException exceptionWithName:@"SUIncorrectAPIUsageException" reason:reason userInfo:nil];
|
||||
@throw exception;
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// To prevent trying to stick an SUUpdater in a nib or initializing it in an incorrect way
|
||||
- (instancetype)init
|
||||
{
|
||||
SULog(SULogLevelError, @"-[%@ init] is not implemented. If you want to drop an updater into a nib, see SPUStandardUpdaterController.", NSStringFromClass([self class]));
|
||||
abort();
|
||||
NSString *reason = [NSString stringWithFormat:@"-[%@ init] is not implemented. If you want to drop an updater into a nib, see SPUStandardUpdaterController.", NSStringFromClass([self class])];
|
||||
SULog(SULogLevelError, reason);
|
||||
|
||||
NSException *exception = [NSException exceptionWithName:@"SUIncorrectAPIUsageException" reason:reason userInfo:nil];
|
||||
@throw exception;
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -614,8 +622,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(SULogLevelError, @"This method must be called on the main thread");
|
||||
abort();
|
||||
SULog(SULogLevelError, @"Error: SPUUpdater -setFeedURL: must be called on the main thread. The call from a background thread was ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
// When feedURL is nil, -absoluteString will return nil and will remove the user default key
|
||||
@@ -625,8 +633,11 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
- (BOOL)retrieveFeedURL:(NSURL * __autoreleasing *)feedURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(SULogLevelError, @"This method must be called on the main thread");
|
||||
abort();
|
||||
SULog(SULogLevelError, @"Error: SPUUpdater -retrieveFeedURL:error: must be called on the main thread.");
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUIncorrectAPIUsageError userInfo:@{ NSLocalizedDescriptionKey: @"SUUpdater -retriveFeedURL:error: must be called on the main thread."}];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
|
||||
@@ -657,14 +668,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return YES;
|
||||
}
|
||||
|
||||
// A client may call this method but do not invoke this method ourselves because its unsafe
|
||||
// A client may call this method but do not invoke this method ourselves because it's unsafe
|
||||
- (NSURL *)feedURL
|
||||
{
|
||||
NSURL *feedURL = nil;
|
||||
NSError *feedError = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:&feedError]) {
|
||||
SULog(SULogLevelError, @"Fatal Feed Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
abort();
|
||||
SULog(SULogLevelError, @"Feed Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
return nil;
|
||||
}
|
||||
return feedURL;
|
||||
}
|
||||
|
||||
Vendored
+4
-1
@@ -56,7 +56,10 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCanceledError = 4007,
|
||||
SUInstallationAuthorizeLaterError = 4008,
|
||||
SUNotAllowedInteractionError = 4009
|
||||
SUNotAllowedInteractionError = 4009,
|
||||
|
||||
// API misuse errors.
|
||||
SUIncorrectAPIUsageError = 5000
|
||||
};
|
||||
|
||||
#endif
|
||||
Vendored
+2
-1
@@ -105,7 +105,8 @@
|
||||
NSString *version = [self _version];
|
||||
if (version == nil) {
|
||||
SULog(SULogLevelError, @"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey);
|
||||
abort();
|
||||
// Instead of abort()-ing, return an empty string to satisfy the _Nonnull contract.
|
||||
return @"";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
Vendored
-1
@@ -86,7 +86,6 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to start updater with error: %@", updaterError);
|
||||
abort();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,7 +56,12 @@
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
NSLog(@"Failed to start updater with error: %@", updaterError);
|
||||
abort();
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"Updater Error";
|
||||
alert.informativeText = @"The Updater failed to start. For detailed error information, check the Console.app log."
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert runModal];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user