try_and_catch
authorMarc Celani <marccelani@fb.com>
Sat, 3 May 2014 01:17:32 +0000 (18:17 -0700)
committerDave Watson <davejwatson@fb.com>
Tue, 20 May 2014 19:53:58 +0000 (12:53 -0700)
commitc31b528b862af14917131eeb9631dd1f5d4d4477
treee5474bbfb4bfc6b347b0a2e0c76b3206a853bff4
parent708b3d777e39d715cf3b1f0e688e95b9bf9fa166
try_and_catch

Summary: A helper function to do try/catch on multiple exception types and store the ressult in an exception_wrapper. The purpose of this function is to best effort mimic std::current_exception(). Unlike std::current_exception(), we need to specify the types that we expect to see. Rather than writing macros or several lines per exception type to capture the exception into an exception_wrapper, this function makes writing try/catch blocks for this purpose very easy.

Test Plan: unit test

Reviewed By: mhorowitz@fb.com

FB internal diff: D1308511

@override-unit-failures
folly/ExceptionWrapper.h
folly/test/ExceptionWrapperTest.cpp