Do not throw when a plugin is already added
Summary: Causes a lot of errors that don't seem to be preventable from a plugin author's perspective and also completely benign. https://www.internalfb.com/logview/flipper_javascript/3b754533c5da4e91fe8c0a3318cf8d5c?trace_tab=latest Reviewed By: lblasa Differential Revision: D48642974 fbshipit-source-id: 5ba542afbaa4175e1657d4b229d8bab62fac9862
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ef6e3df9df
commit
7822099f50
@@ -59,15 +59,17 @@ void FlipperClient::addPlugin(std::shared_ptr<FlipperPlugin> plugin) {
|
||||
performAndReportError([this, plugin]() {
|
||||
log("FlipperClient::addPlugin " + plugin->identifier());
|
||||
auto step = flipperState_->start("Add plugin " + plugin->identifier());
|
||||
auto needs_refresh = false;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (plugins_.find(plugin->identifier()) != plugins_.end()) {
|
||||
throw std::out_of_range(
|
||||
"plugin " + plugin->identifier() + " already added.");
|
||||
log("plugin " + plugin->identifier() + " already added.");
|
||||
} else {
|
||||
plugins_[plugin->identifier()] = plugin;
|
||||
needs_refresh = true;
|
||||
}
|
||||
plugins_[plugin->identifier()] = plugin;
|
||||
step->complete();
|
||||
if (connected_) {
|
||||
if (connected_ && needs_refresh) {
|
||||
refreshPlugins();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user