try: except: in C++

#include <iostream>
using namespace std;

int main()
{
    try
    {
        int a, b;
        cin >> a >> b;
        cout << a / b << endl; //try to divide by 0, you'll see error msg
    }
    catch(exception &e)
    {
        cout << "error happend: " << e.what() << endl;
    }
}