4 ms·
In C++, I like to return fallible values (std::optional or std::expected from C++23 are good choices), and use exceptions as something in between an error and a
by qalmakka 4y ago
In C++, I like to return fallible values (std::optional or std::expected from C++23 are good choices), and use exceptions as something in between an error and an assert.
I personally find that exceptions are very good to handle rare runtime failures that are not expected, and that severely hamper the flow of a program. In general, these cases tend to be rare, and under their circumstances terminating is generally ok. Still, it's nice to give the developer some control over if and when they want to handle it, especially if it is a library.