Summary: It looks like there is no reason to catch a `std::exception` and then `dynamic_cast` to a derived exception. We can just catch the derived exception directly.
whatcouldgowrong4
Reviewed By: yfeldblum
Differential Revision:
D2677284
fb-gh-sync-id:
0149e4d4aecc96257376d410f592620205441f66
} else if (eptr_) {
try {
std::rethrow_exception(eptr_);
- } catch (std::exception& e) {
- return dynamic_cast<const Ex*>(&e);
+ } catch (typename std::decay<Ex>::type&) {
+ return true;
} catch (...) {
// fall through
}
} else if (that->eptr_) {
try {
std::rethrow_exception(that->eptr_);
- } catch (std::exception& e) {
- if (auto ex = dynamic_cast<Ex*>(&e)) {
- f(*ex);
- return true;
- }
+ } catch (Ex& e) {
+ f(e);
+ return true;
} catch (...) {
// fall through
}