Skip to content

Commit

Permalink
Merge pull request #210 from Squirrel/provide-more-error-info
Browse files Browse the repository at this point in the history
Provide more error context when we get POSIX errors
  • Loading branch information
joshaber authored Jul 20, 2017
2 parents 203315f + 523824e commit 5396dcd
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Squirrel/SQRLInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,20 @@ - (RACSignal *)deleteOwnedBundleAtURL:(NSURL *)bundleURL {
if (rmdir(temporaryDirectoryURL.path.fileSystemRepresentation) == 0) {
return [RACSignal empty];
} else {
return [RACSignal error:[NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]];
int code = errno;
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];

const char *desc = strerror(code);
if (desc != NULL) {
userInfo[NSLocalizedDescriptionKey] = @(desc);
} else {
userInfo[NSLocalizedDescriptionKey] = NSLocalizedString(@"Unknown POSIX error", @"");
}

userInfo[NSLocalizedFailureReasonErrorKey] = [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove temp dir \"%@\"", @""), temporaryDirectoryURL.path];
userInfo[NSURLErrorKey] = temporaryDirectoryURL;

return [RACSignal error:[NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:userInfo]];
}
}]
setNameWithFormat:@"%@ -deleteOwnedBundleAtURL: %@", self, bundleURL];
Expand Down Expand Up @@ -530,7 +543,14 @@ - (RACSignal *)clearQuarantineForDirectory:(NSURL *)directory {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];

const char *desc = strerror(code);
if (desc != NULL) userInfo[NSLocalizedDescriptionKey] = @(desc);
if (desc != NULL) {
userInfo[NSLocalizedDescriptionKey] = @(desc);
} else {
userInfo[NSLocalizedDescriptionKey] = NSLocalizedString(@"Unknown POSIX error", @"");
}

userInfo[NSLocalizedFailureReasonErrorKey] = [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove quarantine attribute from \"%@\". This most likely means the file is read-only.", @""), URL.path];
userInfo[NSURLErrorKey] = URL;

return [RACSignal error:[NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:userInfo]];
}
Expand Down

0 comments on commit 5396dcd

Please sign in to comment.