Fixed mistake with Makefile.am for spooky tests.
[folly.git] / folly / String.h
index 906a9f376df7cfccdeb56850d87dd990854a561b..90b761e3e1e784a8babd23d61ba96f941c5a7c60 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef FOLLY_BASE_STRING_H_
 #define FOLLY_BASE_STRING_H_
 
+#include <exception>
 #include <string>
 #include <boost/type_traits.hpp>
 
@@ -285,6 +286,16 @@ inline fbstring exceptionStr(const std::exception& e) {
   return folly::to<fbstring>(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 "<unknown exception>";
+  }
+}
+
 /*
  * Split a string into a list of tokens by delimiter.
  *
@@ -353,6 +364,14 @@ void join(const Delim& delimiter,
   join(delimiter, container.begin(), container.end(), output);
 }
 
+template <class Delim, class Container>
+std::string join(const Delim& delimiter,
+                 const Container& container) {
+  std::string output;
+  join(delimiter, container.begin(), container.end(), output);
+  return output;
+}
+
 } // namespace folly
 
 // Hash functions for string and fbstring usable with e.g. hash_map