4 Comments
User's avatar
Ext3h's avatar

Just a little nitpick: never, and I mean absolutely never catch exceptions as anything but a `const &`.

Compilers can eliminate most of the boiler plate code for the exception itself if you keep the exceptions nice and const. Don't, and the exception handling turns actually quite costly.

Sure, error codes are still much better, but exceptions ain't that bad either when at least used correctly.

Expand full comment
Yacob Cohen-Arazi's avatar

great overview!!

Expand full comment
Henri Hein's avatar

Nicely done.

Expand full comment
Kemal b's avatar

A good read! I have also a blog post on this if you’d like to check out:

https://kemalbektas.dev/c-error-handling-with-style-the-benefits-of-optional-and-expected

Expand full comment