Exception Handling - Kamills-12/2143-OOP GitHub Wiki

Exception Handling

Kade Miller


What Is Exception Handling?

Exception handling is how you catch and deal with errors in your code without crashing the whole program.

Instead of your app blowing up, you can:

  • Catch the error
  • Show a message
  • Recover

C++ gives you this with three keywords:

try {
    // risky code
} catch (...) {
    // handle error
} finally { 
    // optional cleanup (not in C++, but conceptually)
}