itinance / itinance/react-native-fs

Poor/empty exception messages on Android

Open
#63 0 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I struggled to fix the download correctness issue in PR #62 due to the JS error messages being empty on Android. (We were just getting an empty Error object.)

Ideally JS errors and/or logging should provide information from the Java exception. As a quick hack, the below change to RNFSManager.java helped a lot. It turned out to be an HTTP 404 error and was easy to fix after knowing the issue.

I'm not submitting this as a pull request just yet because I suspect react-native may already provide a built-in Exception-to-JS-Error conversion utility function - any thoughts from RN Android devs?

private WritableMap makeErrorPayload(Exception ex) {
WritableMap error = Arguments.createMap();

```
// https://stackoverflow.com/questions/7242596/e-printstacktrace-in-string
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
String s = writer.toString();

//error.putString("message", ex.getMessage());
error.putString("message", s);
// TODO: Consolidate and move ex.printStackTrace() here?

return error;
```

}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.