Relative Content

Tag Archive for c++c++17

How to wrap all API-calls in a uniform error-handler?

I’m dealing with a vendor-provided C-library (let’s call it foo), that offers a multitude of API-calls. All of these functions take a (pre-initialized) handle (of type FOOHandle) and return 0 on success, and some other number on failure. In the latter case, the caller can call the foo_get_errmsg() to get the textual description of the error saved in his own buffer. Nothing too unusual.