From 91ee5f4b77411bcfe65897dbf7a36814836c4b9e Mon Sep 17 00:00:00 2001 From: Tudor Bosman Date: Sat, 13 Oct 2012 18:33:17 -0700 Subject: [PATCH] Add a folly::exceptionStr overload Summary: For std::exception_ptr. Test Plan: . Reviewed By: davejwatson@fb.com FB internal diff: D600345 --- folly/String.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/folly/String.h b/folly/String.h index bd7b0114..90b761e3 100644 --- a/folly/String.h +++ b/folly/String.h @@ -17,6 +17,7 @@ #ifndef FOLLY_BASE_STRING_H_ #define FOLLY_BASE_STRING_H_ +#include #include #include @@ -285,6 +286,16 @@ inline fbstring exceptionStr(const std::exception& e) { return folly::to(demangle(typeid(e)), ": ", e.what()); } +inline fbstring exceptionStr(std::exception_ptr ep) { + try { + std::rethrow_exception(ep); + } catch (const std::exception& e) { + return exceptionStr(e); + } catch (...) { + return ""; + } +} + /* * Split a string into a list of tokens by delimiter. * -- 2.34.1