Exceptions: Difference between revisions
→Catching exceptions: another catch clause for std::exception
(→Defining exceptions: std::exception as base class, and a note) |
(→Catching exceptions: another catch clause for std::exception) |
||
Line 210:
===Catching exceptions===
<cpp>
try {
foo();
Line 216 ⟶ 217:
{
// 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 (...)
Line 221 ⟶ 228:
// handle any type of exception not handled by above catches
}
</cpp>
=={{header|C sharp|C #}}==
|