mardi 12 janvier 2021

Should I write catch (...) after catch (exception& e)?

If I know that in the code there is no programmer-defined exception and want to catch only the one thrown by standard libs, is it enough just to write catch (std::exception& e), or I still need to write after it catch (...) ?

int main()
{
try 
{//something
}
catch (std::exception& e) { /*something*/}
catch (...) {/*something*/} //unnecessary? 
}

So basically it's a question about can I be sure that all throw from std methods and functions are exception derived from std::exception?

Aucun commentaire:

Enregistrer un commentaire