Вам необходимо перебросить вложенное исключение и проверить, что:
const boost::exception_ptr* c =
boost::get_error_info<boost::errinfo_nested_exception>(e);
if(c) try {
boost::rethrow_exception(*c);
} catch(boost::exception const& e) { // or a type derived from it
const std::string* file = boost::get_error_info<boost::errinfo_file_name>(e);
// ...
} catch(...) {
// presumably you don't want the exception to escape if it is
// not derived from boost::exception
}
Я лично использую оболочку get_error_info
, которая возвращает результат boost::get_error_info<some_error_info>(e)
, или, если ничего не найдено, результат get_error_info<some_error_info>(nested)
(рекурсивный вызов здесь) или 0
, если нет вложенного исключения (или оно не error_info
-enabled).
В качестве альтернативы / в качестве дополнения, вы можете указать код проверки выше (другойcatch
пункты) в функции:
std::string const* // or return a tuple of what you examined etc.
examine_exception()
{
try {
throw; // precondition: an exception is active
} catch(boost::exception const& e) {
// as above
return ...;
}
}