33

Errors are thrown with throw and caught with try / catch, so the program does not crash.

C++ 10 lines
int divide(int a, int b) {
    if (b == 0) throw runtime_error("Division by zero");
    return a / b;
}

try {
    cout << divide(10, 0);
} catch (const exception &e) {
    cout << "Error: " << e.what();
}