itinance/react-native-fs

Poor/empty exception messages on Android

オープン

#63 opened on 2016/03/19

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (1,012 件のフォーク)batch import
help wanted

Repository metrics

Stars
 (5,043 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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;

}

コントリビューターガイド