偶尔会遇到一段代码没有捕获异常。到目前为止我不知道可能的原因是什么。
以下代码为例。
申请终止
log::trace( "Initializing" );
try
{
module->Init();
}
catch( const std::exception& e )
{
log::error( "Error initializing module:{}", e.what());
}
catch( ... )
{
log::error( "Unknown exception initializing module" );
}
dmesg:
[ 9.557049] terminate called after throwing an instance of '
[ 9.562655] std::runtime_error
[ 9.565715] '
[ 9.567350] what():
followed by the error message passed to what() which was the generated exception message in init.
有什么我不知道的事情可能会导致异常未被捕获吗?
其实忽略了头文件中的一些东西。该函数被标记为“noexcept”,实际上在抛出异常时导致终止。