diff --git a/04-functions.md b/04-functions.md index abf0d49..d81e754 100644 --- a/04-functions.md +++ b/04-functions.md @@ -538,7 +538,7 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t #include using namespace std; -int throw_if_zero(int i) noexcept { +void throw_if_zero(int i) { if (!i) { throw runtime_error("found a zero"); } @@ -546,15 +546,15 @@ int throw_if_zero(int i) noexcept { } int main() { - cout << "Entering main()\n"; + println("Entering main()"); try { throw_if_zero(1); throw_if_zero(0); } - catch(...) { - println("Caught an exception!"); + catch(exception& e) { + println("Caught an exception: {}", e.what()); } - println("Leaving main()\n"); + println("Leaving main()"); } ```