Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5532d3

Browse files
authored
Catch std::exception& instead of std::runtime_error&
Currently, if any standard exception inherited form `std::exception` will be thrown (like `std::bad_alloc`), the program will be terminated without explanation. May be there are objective reasons to catch exceptions that way, but this is not obvious for me. Thanks!
1 parent 4beee51 commit f5532d3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

03_Drawing_a_triangle/00_Setup/00_Base_code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main() {
3939

4040
try {
4141
app.run();
42-
} catch (const std::runtime_error& e) {
42+
} catch (const std::exception& e) {
4343
std::cerr << e.what() << std::endl;
4444
return EXIT_FAILURE;
4545
}
@@ -63,7 +63,7 @@ Once the window is closed and `mainLoop` returns, we'll make sure to deallocate
6363
the resources we've used in the `cleanup` function.
6464

6565
If any kind of fatal error occurs during execution then we'll throw a
66-
`std::runtime_error` exception with a descriptive message, which will propagate
66+
`std::exception` exception with a descriptive message, which will propagate
6767
back to the `main` function and be printed to the command prompt. One example of
6868
an error that we will deal with soon is finding out that a certain required
6969
extension is not supported.

0 commit comments

Comments
 (0)