From f8ff6fe1b2949ac3131cd1a8236e43a56f620572 Mon Sep 17 00:00:00 2001 From: John Knox Date: Mon, 18 Feb 2019 11:23:12 -0800 Subject: [PATCH] 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 --- xplat/Flipper/FlipperResponderImpl.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xplat/Flipper/FlipperResponderImpl.h b/xplat/Flipper/FlipperResponderImpl.h index e5e25c063..bb5706e70 100644 --- a/xplat/Flipper/FlipperResponderImpl.h +++ b/xplat/Flipper/FlipperResponderImpl.h @@ -11,6 +11,7 @@ #include #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"); + } } }