RosettaCodeData/Task/Exceptions/C++/exceptions-4.cpp

18 lines
354 B
C++
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
try {
foo();
}
catch (MyException &exc)
{
// handle exceptions of type MyException and derived
}
catch (std::exception &exc)
{
// handle exceptions derived from std::exception, which were not handled by above catches
// e.g.
std::cerr << exc.what() << std::endl;
}
catch (...)
{
// handle any type of exception not handled by above catches
}