Let Future::then call callbacks outside of the catch handler
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 30 Dec 2016 01:25:26 +0000 (17:25 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 30 Dec 2016 01:32:53 +0000 (17:32 -0800)
commit1d36d4649eb1f80a7741a9b71902dbf5e9b6dc61
treef5149cf696f87f5b8ca7c15f584a4220c3ea37a3
parent686092cb22fbe4ddb4ffefec9b9bf0ae000d2f68
Let Future::then call callbacks outside of the catch handler

Summary:
[Folly] Let `Future::then` call callbacks outside of the catch handler.

And `Future::onError`.

This makes the behavior of calls to `Future` callbacks with respect to currently-handled ("active") exceptions consistent - there will not be an active exception by the time the `Future` callback is called. (Unless `Future::then` or `Future::onError`, etc., is itself called with an active exception. Or unless the `Promise` is fulfilled, outside of the `Future` implementation code, with an active exception.)

This will affect any code which tries to call `std::current_exception()` or `throw;` from within a `Future` callback, such as an `onError` handler. That code will crash. (It was incorrect anyway, and relied on misusing Folly Futures.)

Reviewed By: ericniebler

Differential Revision: D4372173

fbshipit-source-id: 600b22e4db63c98358de29a6abcee807fbc53b0f
folly/futures/Future-inl.h