don't set nested exception if already set

This commit is contained in:
Ed Catmur 2022-06-28 15:50:28 +01:00
parent 1bd0eaae06
commit a8046ffe2d
1 changed files with 2 additions and 1 deletions

View File

@ -581,7 +581,8 @@ public:
error_already_set()
: m_fetched_error{new detail::error_fetch_and_normalize("pybind11::error_already_set"),
m_fetched_error_deleter} {
static_cast<std::nested_exception&>(*this) = m_fetched_error->get_cause_as_nested();
if (not nested_ptr())
static_cast<std::nested_exception&>(*this) = m_fetched_error->get_cause_as_nested();
}
/// The what() result is built lazily on demand.