#include #include #include using namespace std; int main() { vectordata{1,3,5,7,9}; cout << "Throwing and catching an exception " << endl; try { throw exception(); } catch (const exception & e) { cout << "\t\tCaught " << e.what() << endl; } cout << endl << endl; cout << "Catching an exception, but note the message changes" << endl; cout << endl; try { cout << "Data.at(data.size()) is " << endl; throw range_error("This is a dumb thing"); cout << endl; cout << data.at(data.size()) << endl; cout << "And that is that " << endl; cout << endl; } catch (const out_of_range & e) { cout << "\t\tCaught OOR " << e.what() << endl; } catch (const logic_error & e) { cout << "\t\tCaught LE " << e.what() << endl; } catch (const exception & e) { cout << "\t\tCaught EXCEPT " << e.what() << endl; } catch (...) { cout << "In the generic excption handler" << endl; } cout << endl << endl; return 0; }