Don't throw when reporting network request

Summary: Flipper should never crash the mobile app. This is a plugin entry point, so it's understandable that it can, but we should avoid it whenever possible.

Reviewed By: passy

Differential Revision: D20648373

fbshipit-source-id: f32b428cccdd0c78eb15e9e95a64ecf3f4e10429
This commit is contained in:
John Knox
2020-03-25 17:35:28 -07:00
committed by Facebook GitHub Bot
parent 39f0e0445e
commit a30d5f3e60

View File

@@ -34,18 +34,24 @@ public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements Netw
}
@Override
public void reportRequest(RequestInfo requestInfo) {
final FlipperObject request =
new FlipperObject.Builder()
.put("id", requestInfo.requestId)
.put("timestamp", requestInfo.timeStamp)
.put("method", requestInfo.method)
.put("url", requestInfo.uri)
.put("headers", toFlipperObject(requestInfo.headers))
.put("data", toBase64(requestInfo.body))
.build();
public void reportRequest(final RequestInfo requestInfo) {
(new ErrorReportingRunnable(getConnection()) {
@Override
protected void runOrThrow() throws Exception {
final FlipperObject request =
new FlipperObject.Builder()
.put("id", requestInfo.requestId)
.put("timestamp", requestInfo.timeStamp)
.put("method", requestInfo.method)
.put("url", requestInfo.uri)
.put("headers", toFlipperObject(requestInfo.headers))
.put("data", toBase64(requestInfo.body))
.build();
send("newRequest", request);
send("newRequest", request);
}
})
.run();
}
@Override