Suppress crash due to Flipper Plugins
Summary: This diff wraps the call to refresh plugins in `performAndReport`. All the important methods are already wrapped in this function. This diff also logs the error in the standard error if the connection is not established. With this diff the iOS app should not crash due exceptions thrown in iOS and cpp code. For android the app won't crash due to exception of cpp but can crash due to exceptions thrown in java code of the plugin Reviewed By: jknoxville Differential Revision: D9848112 fbshipit-source-id: 689ef9240e47400e8ce8c89b4c0ccec43d2180f9
This commit is contained in:
committed by
Facebook Github Bot
parent
79b2cf712d
commit
e763c5cd15
@@ -15,6 +15,9 @@
|
|||||||
#include "ConnectionContextStore.h"
|
#include "ConnectionContextStore.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#if FB_SONARKIT_ENABLED
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
@@ -99,8 +102,10 @@ void SonarClient::disconnect(std::shared_ptr<SonarPlugin> plugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::refreshPlugins() {
|
void SonarClient::refreshPlugins() {
|
||||||
dynamic message = dynamic::object("method", "refreshPlugins");
|
performAndReportError([this]() {
|
||||||
socket_->sendMessage(message);
|
dynamic message = dynamic::object("method", "refreshPlugins");
|
||||||
|
socket_->sendMessage(message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::onConnected() {
|
void SonarClient::onConnected() {
|
||||||
@@ -197,11 +202,13 @@ void SonarClient::performAndReportError(const std::function<void()>& func) {
|
|||||||
try {
|
try {
|
||||||
func();
|
func();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
if (connected_) {
|
|
||||||
dynamic message = dynamic::object(
|
dynamic message = dynamic::object(
|
||||||
"error",
|
"error",
|
||||||
dynamic::object("message", e.what())("stacktrace", "<none>"));
|
dynamic::object("message", e.what())("stacktrace", "<none>"));
|
||||||
|
if (connected_) {
|
||||||
socket_->sendMessage(message);
|
socket_->sendMessage(message);
|
||||||
|
} else {
|
||||||
|
log("SonarError : " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user