Skip to content

Commit 600e0ba

Browse files
committed
improve error message on iOS
1 parent 9126795 commit 600e0ba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

ios/RNZipArchive.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ @implementation RNZipArchive
3737

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

40-
BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:nil error:nil delegate:self];
40+
NSError *error = nil;
41+
42+
BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:nil error:&error delegate:self];
4143

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

4446
if (success) {
4547
resolve(destinationPath);
4648
} else {
47-
NSError *error = nil;
48-
reject(@"unzip_error", @"unable to unzip", error);
49+
reject(@"unzip_error", [error localizedDescription], error);
4950
}
5051
}
5152

@@ -57,14 +58,15 @@ @implementation RNZipArchive
5758

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

60-
BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:password error:nil delegate:self];
61+
NSError *error = nil;
62+
63+
BOOL success = [SSZipArchive unzipFileAtPath:from toDestination:destinationPath overwrite:YES password:password error:&error delegate:self];
6164

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

6467
if (success) {
6568
resolve(destinationPath);
6669
} else {
67-
NSError *error = nil;
6870
reject(@"unzip_error", @"unable to unzip", error);
6971
}
7072
}
@@ -104,7 +106,7 @@ @implementation RNZipArchive
104106
resolver:(RCTPromiseResolveBlock)resolve
105107
rejecter:(RCTPromiseRejectBlock)reject) {
106108
[self zipArchiveProgressEvent:0 total:1 filePath:destinationPath]; // force 0%
107-
109+
108110
NSFileManager *fileManager = [[NSFileManager alloc] init];
109111
BOOL isDir;
110112
BOOL success;
@@ -114,9 +116,9 @@ @implementation RNZipArchive
114116
} else {
115117
success = [SSZipArchive createZipFileAtPath:destinationPath withFilesAtPaths:@[from] withPassword:password];
116118
}
117-
119+
118120
[self zipArchiveProgressEvent:1 total:1 filePath:destinationPath]; // force 100%
119-
121+
120122
if (success) {
121123
resolve(destinationPath);
122124
} else {

0 commit comments

Comments
 (0)