Catch all throwables in FlipperResponder destructor

Summary: Exceptions should never be thrown from destructors, because if an exception is already propogating at the time the destructor is called. Program will terminate.

Reviewed By: passy

Differential Revision: D14123526

fbshipit-source-id: 15ff74f4f14eb28a586055e1b1a5d54231b549da
This commit is contained in:
John Knox
2019-02-18 11:23:12 -08:00
committed by Facebook Github Bot
parent 84240ede4e
commit f8ff6fe1b2

View File

@@ -11,6 +11,7 @@
#include <rsocket/RSocketResponder.h>
#include "FlipperConnectionManager.h"
#include "FlipperResponder.h"
#include "Log.h"
namespace facebook {
namespace flipper {
@@ -38,8 +39,16 @@ class FlipperResponderImpl : public FlipperResponder {
~FlipperResponderImpl() {
if (!isCompleted) {
downstreamObserver_->onSuccess(
folly::dynamic::object("success", folly::dynamic::object()));
try {
downstreamObserver_->onSuccess(
folly::dynamic::object("success", folly::dynamic::object()));
} catch (std::exception& e) {
log(std::string(
"Exception occurred when responding in FlipperResponder: ") +
e.what());
} catch (...) {
log("Exception occurred when responding in FlipperResponder");
}
}
}