try { //do something } catch (const std::exception& e) { std::cout << e.what(); // information from error printed }
#include #include #include using namespace std; void MyFunc(int c) { if (c > numeric_limits< char> ::max()) throw invalid_argument("MyFunc argument too large."); //... }