|
|
|
|
|
by grandinj
1777 days ago
|
|
On the other hand () they solve a handful of use-cases really really well. () if you are writing relatively decent C++, most code is pretty much exception safe already () lots of abstractions are dangerous when mis-used () they are sufficiently low cost that they almost never show up in the fairly extensive perf profiling I do on a large real-world application (LibreOffice). And LibreOffice throws exceptions __a lot__ (*) Except for toolchain writers, nobody cares how they are implemented |
|
They're terrible for this. C++ Exceptions are a perfectly good exception mechanism, but what C++ programmers are trained to do with them isn't exceptions but error handling and they're not suitable for that.
"I tried to create the file but it already existed" is an error - and now you're going to write the unhappy path code, this is the wrong place to have exceptions.
"I tried to create the file but the OS now says the abstract concept of files is alien to it" is an exception. You are not prepared for this eventuality, the best you can do is explain to the user as best possible what happened and hope a human knows what to do.