我有一个try catch子句,其中最外层catch(...)从未发生过.经过一些更改后,某个地方会抛出一个我无法处理其他情况的异常.有没有办法获得至少一些关于异常的信息,即使我抓住了它(...)?
catch (const cone::BeginnersLibException& ex)
{
// handle the exception
}
catch (const std::exception& ex)
{
// handle std exception
}
catch (...)
{
log("Unknown exception caught.");
// How can I get more information about this exception?
}
Run Code Online (Sandbox Code Playgroud)
编辑:这里有一个适合我的代码片段:
#include <cxxabi.h>
// more code here
} catch (...) {
std::string exName(abi::__cxa_current_exception_type()->name());
std::cout<<"unknown exception: "<< exName <<std::endl;
throw;
}
Run Code Online (Sandbox Code Playgroud) 有没有办法在这里获得至少一些信息?
...
catch(...)
{
std::cerr << "Unhandled exception" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我把它作为我所有代码的最后手段.让它崩溃会更好吗,因为那时我至少可以得到崩溃报告?