From: Tudor Bosman Date: Sun, 14 Oct 2012 01:33:17 +0000 (-0700) Subject: Add a folly::exceptionStr overload X-Git-Tag: v0.22.0~1169 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=91ee5f4b77411bcfe65897dbf7a36814836c4b9e;p=folly.git Add a folly::exceptionStr overload Summary: For std::exception_ptr. Test Plan: . Reviewed By: davejwatson@fb.com FB internal diff: D600345 --- 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. *