Ho una clausola catch try in cui il più esterno catch(...)
non è mai successo fino ad ora. Dopo alcune modifiche, viene generata un'eccezione che non gestisco con gli altri casi. C'è un modo per ottenere almeno alcune informazioni sull'eccezione anche se la prendo con (...)
?Ottieni informazioni dall'eccezione catturata con 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?
}
Edit: ecco un frammento di codice che funziona per me:
#include <cxxabi.h>
// more code here
} catch (...) {
std::string exName(abi::__cxa_current_exception_type()->name());
std::cout<<"unknown exception: "<< exName <<std::endl;
throw;
}
Se un'eccezione deriva da 'std :: exception', puoi chiamare' catch (const std :: exception & exc) 'e quindi usare' exc.what() ' – Mints97
@ Mints97: sicuro, ma quello non è l'OP situazione. –
Manca uno snippet di codice – Niall