Skip to content

Commit

Permalink
Merge pull request sparkle-project#1566 from bdkjones/2.x
Browse files Browse the repository at this point in the history
Better Appcast Errors
  • Loading branch information
kornelski authored Mar 26, 2020
2 parents 5270fe0 + ba8dd4d commit 80627a4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Sparkle/SUAppcast.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,14 @@ - (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)background completio
} else {
SULog(SULogLevelError, @"Encountered download feed error: %@", error);

NSDictionary *userInfo = [NSDictionary
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
forKey: NSLocalizedDescriptionKey];
NSMutableDictionary *userInfo = [NSMutableDictionary
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
forKey: NSLocalizedDescriptionKey];

if (error != nil) {
NSError *assignedError = error; // Silences a Clang warning about implicit conversion from Nullable to Nonnull.
[userInfo setObject:assignedError forKey:NSUnderlyingErrorKey];
}

[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
code:SUDownloadError
Expand Down Expand Up @@ -258,12 +263,17 @@ -(NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData error:(NSError *_

- (void)reportError:(NSError *)error
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
}];

NSMutableDictionary *userInfo = [error.userInfo mutableCopy];

if (!userInfo)
{
userInfo = [[NSMutableDictionary alloc] initWithDictionary:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
}];
}

NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
if (failingUrl) {
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
Expand Down

0 comments on commit 80627a4

Please sign in to comment.