Commit 91ee5f4b authored by Tudor Bosman's avatar Tudor Bosman Committed by Jordan DeLong

Add a folly::exceptionStr overload

Summary: For std::exception_ptr.

Test Plan: .

Reviewed By: davejwatson@fb.com

FB internal diff: D600345
parent 636f38ca
......@@ -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.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment