/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2016-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return nullptr;
}
}
+} // namespace
+
+exception_wrapper exception_wrapper::from_exception_ptr(
+ std::exception_ptr const& ptr) noexcept {
+ if (!ptr) {
+ return exception_wrapper();
+ }
+ try {
+ std::rethrow_exception(ptr);
+ } catch (std::exception& e) {
+ return exception_wrapper(std::current_exception(), e);
+ } catch (...) {
+ return exception_wrapper(std::current_exception());
+ }
}
exception_wrapper::exception_wrapper(std::exception_ptr ptr) noexcept