Skip to content

Commit 13bc69b

Browse files
authored
Merge pull request #755 from ziphr/ONRECEIVE-FATAL-ERROR
fix: callback invoke
2 parents 4abb972 + 18d882e commit 13bc69b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,13 @@ public void onReceive(Context context, Intent intent) {
751751
Cursor c = dm.query(query);
752752
// #236 unhandled null check for DownloadManager.query() return value
753753
if (c == null) {
754-
this.callback.invoke("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
755-
return;
754+
try {
755+
this.callback.invoke("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
756+
return;
757+
}
758+
catch(Exception e) {
759+
return;
760+
}
756761
}
757762

758763
String filePath = null;
@@ -762,8 +767,13 @@ public void onReceive(Context context, Intent intent) {
762767
// #297 handle failed request
763768
int statusCode = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
764769
if(statusCode == DownloadManager.STATUS_FAILED) {
765-
this.callback.invoke("Download manager failed to download from " + this.url + ". Status Code = " + statusCode, null, null);
766-
return;
770+
try {
771+
this.callback.invoke("Download manager failed to download from " + this.url + ". Query was unsuccessful ", null, null);
772+
return;
773+
}
774+
catch(Exception e) {
775+
return;
776+
}
767777
}
768778
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
769779
if ( contentUri != null &&

0 commit comments

Comments
 (0)