Change performAndReportError to handle exception pointers
Summary: Since plugins aren't under our control, they might throw exception pointers. We can still extract the useful info in this case. Reviewed By: passy Differential Revision: D14244362 fbshipit-source-id: 5f18100c08160e7514b3fd88ec47809cb37e9770
This commit is contained in:
committed by
Facebook Github Bot
parent
e594176401
commit
85c041ff8d
@@ -302,6 +302,20 @@ void FlipperClient::performAndReportError(const std::function<void()>& func) {
|
|||||||
try {
|
try {
|
||||||
func();
|
func();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
|
handleError(e);
|
||||||
|
} catch (std::exception* e) {
|
||||||
|
if (e) {
|
||||||
|
handleError(*e);
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
// Generic catch block for the exception of type not belonging to
|
||||||
|
// std::exception
|
||||||
|
log("Unknown error suppressed in FlipperClient");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlipperClient::handleError(std::exception& e) {
|
||||||
if (connected_) {
|
if (connected_) {
|
||||||
std::string callstack = this->callstack();
|
std::string callstack = this->callstack();
|
||||||
dynamic message = dynamic::object(
|
dynamic message = dynamic::object(
|
||||||
@@ -312,12 +326,6 @@ void FlipperClient::performAndReportError(const std::function<void()>& func) {
|
|||||||
} else {
|
} else {
|
||||||
log("Error: " + std::string(e.what()));
|
log("Error: " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
} catch (...) {
|
|
||||||
// Generic catch block for the exception of type not belonging to
|
|
||||||
// std::exception
|
|
||||||
log("Unknown error suppressed in FlipperClient");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FlipperClient::getState() {
|
std::string FlipperClient::getState() {
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class FlipperClient : public FlipperConnectionManager::Callbacks {
|
|||||||
void disconnect(std::shared_ptr<FlipperPlugin> plugin);
|
void disconnect(std::shared_ptr<FlipperPlugin> plugin);
|
||||||
void startBackgroundPlugins();
|
void startBackgroundPlugins();
|
||||||
std::string callstack();
|
std::string callstack();
|
||||||
|
void handleError(std::exception& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace flipper
|
} // namespace flipper
|
||||||
|
|||||||
Reference in New Issue
Block a user