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 @Override
public void reportRequest(RequestInfo requestInfo) { public void reportRequest(final RequestInfo requestInfo) {
final FlipperObject request = (new ErrorReportingRunnable(getConnection()) {
new FlipperObject.Builder() @Override
.put("id", requestInfo.requestId) protected void runOrThrow() throws Exception {
.put("timestamp", requestInfo.timeStamp) final FlipperObject request =
.put("method", requestInfo.method) new FlipperObject.Builder()
.put("url", requestInfo.uri) .put("id", requestInfo.requestId)
.put("headers", toFlipperObject(requestInfo.headers)) .put("timestamp", requestInfo.timeStamp)
.put("data", toBase64(requestInfo.body)) .put("method", requestInfo.method)
.build(); .put("url", requestInfo.uri)
.put("headers", toFlipperObject(requestInfo.headers))
.put("data", toBase64(requestInfo.body))
.build();
send("newRequest", request); send("newRequest", request);
}
})
.run();
} }
@Override @Override