Skip to content

Commit

Permalink
improve error message on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
plrthink committed Aug 17, 2019
1 parent 9126795 commit 600e0ba
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ios/RNZipArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ @implementation RNZipArchive

[self zipArchiveProgressEvent:0 total:1 filePath:from]; // force 0%

BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:nil error:nil delegate:self];
NSError *error = nil;

BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:nil error:&error delegate:self];

[self zipArchiveProgressEvent:1 total:1 filePath:from]; // force 100%

if (success) {
resolve(destinationPath);
} else {
NSError *error = nil;
reject(@"unzip_error", @"unable to unzip", error);
reject(@"unzip_error", [error localizedDescription], error);
}
}

Expand All @@ -57,14 +58,15 @@ @implementation RNZipArchive

[self zipArchiveProgressEvent:0 total:1 filePath:from]; // force 0%

BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:password error:nil delegate:self];
NSError *error = nil;

BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:password error:&error delegate:self];

[self zipArchiveProgressEvent:1 total:1 filePath:from]; // force 100%

if (success) {
resolve(destinationPath);
} else {
NSError *error = nil;
reject(@"unzip_error", @"unable to unzip", error);
}
}
Expand Down Expand Up @@ -104,7 +106,7 @@ @implementation RNZipArchive
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self zipArchiveProgressEvent:0 total:1 filePath:destinationPath]; // force 0%

NSFileManager *fileManager = [[NSFileManager alloc] init];
BOOL isDir;
BOOL success;
Expand All @@ -114,9 +116,9 @@ @implementation RNZipArchive
} else {
success = [SSZipArchive createZipFileAtPath:destinationPath withFilesAtPaths:@[from] withPassword:password];
}

[self zipArchiveProgressEvent:1 total:1 filePath:destinationPath]; // force 100%

if (success) {
resolve(destinationPath);
} else {
Expand Down

0 comments on commit 600e0ba

Please sign in to comment.