Exceptions or Error Return Codes?

In the initial version of my WinReg C++ library, I made a design decision that methods that wrapped Win32 Registry C API calls would throw C++ exceptions on errors.

Important feedback I got from the users of this library was that they wanted methods that returned error codes instead of throwing exceptions (e.g., see this issue).

For example, when opening a registry key, folks want to be able to check the result of the operation without having exceptions thrown from failed opens. Similarly when trying to read values from the registry.

This is a good remainder for those C++ devs who think that we should always throw exceptions instead of using error return codes!


Some links on writing exception-safe code in C++

I found a very interesting thread on StackOverflow about writing exception safe code in C++:

C++: do you (really) write exception safe code?

The first answer is worth reading.

And, as already written in the aforementioned thread, detailed information on this subject can be found on GotW website, too:

GotW #59: Exception-Safe Class Design, Part 1: Copy Assignment

GotW #60: Exception-Safe Class Design, Part 2: Inheritance