Browse Source

fix io exception in RNFetchBlobReq

Tyler Pexton 4 years ago
parent
commit
d06e2e92d9
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 8
- 2
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

592
                 }
592
                 }
593
 
593
 
594
                 RNFetchBlobFileResp rnFetchBlobFileResp;
594
                 RNFetchBlobFileResp rnFetchBlobFileResp;
595
-                
595
+
596
                 try {
596
                 try {
597
                     rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
597
                     rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
598
                 } catch (ClassCastException ex) {
598
                 } catch (ClassCastException ex) {
599
                     // unexpected response type
599
                     // unexpected response type
600
                     if (responseBody != null) {
600
                     if (responseBody != null) {
601
-                        callback.invoke("Unexpected FileStorage response file: " + responseBody.body().string(), null);
601
+                        String responseBodyString = null;
602
+                        try {
603
+                            responseBodyString = responseBody.string();
604
+                        } catch(IOException exception) {
605
+                            exception.printStackTrace();
606
+                        }
607
+                        callback.invoke("Unexpected FileStorage response file: " + responseBodyString, null);
602
                     } else {
608
                     } else {
603
                         callback.invoke("Unexpected FileStorage response with no file.", null);
609
                         callback.invoke("Unexpected FileStorage response with no file.", null);
604
                     }
610
                     }