Commit 266ccb57 authored by Chad Parry's avatar Chad Parry Committed by facebook-github-bot-1

Recommend a different exception_handler idiom

Summary: This is a //tiny// documentation change. I noticed that there are lots of places in the codebase where people follow this recommended usage of `with_exception` in an if–else chain, (e.g., https://fburl.com/181606454). IMHO, a short-circuiting `||` operator is easier to read and write.

Reviewed By: yfeldblum

Differential Revision: D2687840

fb-gh-sync-id: 6354555aeba81dcfe7adf17e7e573de0b1206b37
parent 632fb9b5
...@@ -88,16 +88,15 @@ namespace folly { ...@@ -88,16 +88,15 @@ namespace folly {
* *
* // Thread2: Exceptions are bad! * // Thread2: Exceptions are bad!
* void processResult() { * void processResult() {
* auto ep = globalExceptionWrapper.get(); * globalExceptionWrapper.with_exception(
* if (!ep.with_exception([&]( * [&](FacePlantException& faceplant) {
* FacePlantException& faceplant) { * LOG(ERROR) << "FACEPLANT";
* LOG(ERROR) << "FACEPLANT"; * }) ||
* })) { * globalExceptionWrapper.with_exception(
* ep.with_exception([&]( * [&](FailWhaleException& failwhale) {
* FailWhaleException& failwhale) {
* LOG(ERROR) << "FAILWHALE!"; * LOG(ERROR) << "FAILWHALE!";
* }); * }) ||
* } * LOG(FATAL) << "Unrecognized exception";
* } * }
* *
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment