#include <iostream>
#include <stdexcept>
using namespace std;
//any method can throw an exception
void methodWithException() {
throw runtime_error("test exception");
}
try {
methodWithException();
}
catch (runtime_error & e) {
cout << e.what();
}