Catch receiver errors
Summary: This change adds a safety net for receivers that may throw an exception on invocation. Without this change, the exception is logged but not shown in Flipper. Reviewed By: nikoant Differential Revision: D34001224 fbshipit-source-id: ca07d3dd006b277e306ecbc1c033845929a83f4c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4f9cec718e
commit
fd3d4d4efb
@@ -33,7 +33,15 @@ class FlipperConnectionImpl : public FlipperConnection {
|
|||||||
responder->error(folly::dynamic::object("message", errorMessage));
|
responder->error(folly::dynamic::object("message", errorMessage));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
receivers_.at(method)(params, responder);
|
receivers_.at(method)(params, responder);
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
std::string errorMessage = "Receiver " + method + " failed with error. ";
|
||||||
|
std::string reason = ex.what();
|
||||||
|
errorMessage += "Error: '" + reason + "'.";
|
||||||
|
log("Error: " + errorMessage);
|
||||||
|
responder->error(folly::dynamic::object("message", errorMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(const std::string& method, const folly::dynamic& params) override {
|
void send(const std::string& method, const folly::dynamic& params) override {
|
||||||
|
|||||||
Reference in New Issue
Block a user