try, catch and throw in C++ — a practical guide to C++ try catch throw with clear examples you can reuse in real projects.
C++ Tutorial Series (75/111). Prefer one article? Read the complete C++ tutorial.
Short description
Catch std::exception const& for standard errors.
try/catch
try {
throw std::runtime_error("boom");
} catch (const std::exception& ex) {
std::cerr << ex.what() << 'n';
}