浏览代码

Merge pull request #530 from joltup/filestorage-class-cast-exception-1

Update RNFetchBlobReq.java
Travis Nuttall 4 年前
父节点
当前提交
a10c81d658
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 11
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java 查看文件

@@ -591,7 +591,17 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
591 591
 //                    ignored.printStackTrace();
592 592
                 }
593 593
 
594
-                RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
594
+                try {
595
+                    RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
596
+                } catch (ClassCastException ex) {
597
+                    // unexpected response type
598
+                    if (responseBody != null) {
599
+                        callback.invoke("Unexpected FileStorage response file: " + responseBody.string(), null);
600
+                    } else {
601
+                        callback.invoke("Unexpected FileStorage response with no file.", null);
602
+                    }
603
+                    return;
604
+                }
595 605
 
596 606
                 if(rnFetchBlobFileResp != null && !rnFetchBlobFileResp.isDownloadComplete()){
597 607
                     callback.invoke("Download interrupted.", null);