How do I make a call to what() on std::exception_ptr

前端 未结 4 1761
别那么骄傲
别那么骄傲 2020-12-28 13:26

This is the code I have.

try
{
// code throws potentially unknown exception
}
catch (...)
{
    std::exception_ptr eptr =  std::current_exception();
             


        
4条回答
  •  萌比男神i
    2020-12-28 14:04

    try
    {
       std::rethrow_exception(eptr);
    }
    catch (const std::exception& e)
    {
       std::cerr << e.what() << std::endl;
    }
    

    http://en.cppreference.com/w/cpp/error/exception_ptr

提交回复
热议问题