From 2833ce1b88dca29d2b2a172f31cde28aaa14a0b8 Mon Sep 17 00:00:00 2001 From: Marc Celani <marccelani@fb.com> Date: Tue, 6 May 2014 19:05:02 -0700 Subject: [PATCH] Allow for folly::exception_wrapper in ClientReceiveState Summary: This diff allows us to use folly::exception_wrapper in ClientReceiveState. Existing use cases are still supported (crs.exception() still returns an exception_ptr no matter what), but we can now choose to set an exception without throwing first. On the folly side, add some new functions for making an exception_ptr from an exception_wrapper. Test Plan: Reran unit tests Reviewed By: davejwatson@fb.com FB internal diff: D1307027 @override-unit-failures --- folly/ExceptionWrapper.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index 89ef616f..a18ee1f0 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -121,6 +121,14 @@ class exception_wrapper { explicit operator bool() const { return get(); } + std::exception_ptr getExceptionPtr() const { + try { + throwException(); + } catch (...) { + return std::current_exception(); + } + } + private: std::shared_ptr<std::exception> item_; void (*throwfn_)(std::exception*); -- 2.34.1