@@ -64,7 +64,7 @@ public void isPasswordProtected(final String zipFilePath, final Promise promise)
6464 net .lingala .zip4j .ZipFile zipFile = new net .lingala .zip4j .ZipFile (zipFilePath );
6565 promise .resolve (zipFile .isEncrypted ());
6666 } catch (ZipException ex ) {
67- promise .reject (null , String .format ("Unable to check for encryption due to: %s" , getStackTrace (ex )));
67+ promise .reject ("RNZipArchiveError" , String .format ("Unable to check for encryption due to: %s" , getStackTrace (ex )));
6868 }
6969 }
7070
@@ -79,7 +79,7 @@ public void run() {
7979 if (zipFile .isEncrypted ()) {
8080 zipFile .setPassword (password .toCharArray ());
8181 } else {
82- promise .reject (null , String .format ("Zip file: %s is not password protected" , zipFilePath ));
82+ promise .reject ("RNZipArchiveError" , String .format ("Zip file: %s is not password protected" , zipFilePath ));
8383 }
8484
8585 List fileHeaderList = zipFile .getFileHeaders ();
@@ -107,7 +107,7 @@ public void run() {
107107 promise .resolve (Arguments .fromList (extractedFileNames ));
108108 } catch (Exception ex ) {
109109 updateProgress (0 , 1 , zipFilePath ); // force 0%
110- promise .reject (null , String .format ("Failed to unzip file, due to: %s" , getStackTrace (ex )));
110+ promise .reject ("RNZipArchiveError" , String .format ("Failed to unzip file, due to: %s" , getStackTrace (ex )));
111111 }
112112 }
113113 }).start ();
@@ -122,7 +122,7 @@ public void run() {
122122 try {
123123 new File (zipFilePath );
124124 } catch (NullPointerException e ) {
125- promise .reject (null , "Couldn't open file " + zipFilePath + ". " );
125+ promise .reject ("RNZipArchiveError" , "Couldn't open file " + zipFilePath + ". " );
126126 return ;
127127 }
128128
@@ -174,7 +174,7 @@ public void run() {
174174 }
175175 } catch (Exception ex ) {
176176 updateProgress (0 , 1 , zipFilePath ); // force 0%
177- promise .reject (null , "Failed to extract file " + ex .getLocalizedMessage ());
177+ promise .reject ("RNZipArchiveError" , "Failed to extract file " + ex .getLocalizedMessage ());
178178 }
179179 }
180180 }).start ();
@@ -212,7 +212,7 @@ public void run() {
212212 compressedSize = fileDescriptor .getLength ();
213213 }
214214 } catch (IOException e ) {
215- promise .reject (null , String .format ("Asset file `%s` could not be opened" , assetsPath ));
215+ promise .reject ("RNZipArchiveError" , String .format ("Asset file `%s` could not be opened" , assetsPath ));
216216 return ;
217217 }
218218
@@ -274,7 +274,7 @@ public void run() {
274274 throw new Exception (String .format ("Couldn't extract %s" , assetsPath ));
275275 }
276276 } catch (Exception ex ) {
277- promise .reject (null , ex .getMessage ());
277+ promise .reject ("RNZipArchiveError" , ex .getMessage ());
278278 return ;
279279 }
280280 promise .resolve (destDirectory );
@@ -338,13 +338,13 @@ private void zipWithPassword(final ArrayList<Object> filesOrDirectory, final Str
338338 Log .d (TAG , "Encryption type not supported default to Standard Encryption" );
339339 }
340340 } else {
341- promise .reject (null , "Password is empty" );
341+ promise .reject ("RNZipArchiveError" , "Password is empty" );
342342 }
343343
344344 processZip (filesOrDirectory , destFile , parameters , promise , password .toCharArray ());
345345
346346 } catch (Exception ex ) {
347- promise .reject (null , ex .getMessage ());
347+ promise .reject ("RNZipArchiveError" , ex .getMessage ());
348348 return ;
349349 }
350350
@@ -360,7 +360,7 @@ private void zip(final ArrayList<Object> filesOrDirectory, final String destFile
360360 processZip (filesOrDirectory , destFile , parameters , promise , null );
361361
362362 } catch (Exception ex ) {
363- promise .reject (null , ex .getMessage ());
363+ promise .reject ("RNZipArchiveError" , ex .getMessage ());
364364 return ;
365365 }
366366 }
@@ -410,14 +410,14 @@ public void run() {
410410 }
411411 }
412412 else {
413- promise .reject (null , "File or folder does not exist" );
413+ promise .reject ("RNZipArchiveError" , "File or folder does not exist" );
414414 }
415415
416416 updateProgress (1 , 1 , destFile ); // force 100%
417417 }
418418 promise .resolve (destFile );
419419 } catch (Exception ex ) {
420- promise .reject (null , ex .getMessage ());
420+ promise .reject ("RNZipArchiveError" , ex .getMessage ());
421421 return ;
422422 }
423423 }
0 commit comments