OpenAL and error handling

I'm writing a thin wrapper for OpenAL that only does some basic checking after doing some work.
After writing a few modifier/inspector methods, one thing is impossible to miss. The error handling mechanism in OpenAL is not exactly the most user (in this case user-programmer) friendly.

OpenAL was designed as a C library (which I fully support, although I would like an official C++ wrapper, so that there was no need to reinvent the wheel). After that decision, using C++ exceptions was really not an option anymore. So they were left with returning NULL/an error code or going the errno way. Set an error code and leave it up to the user-programmer to poll it.

Why, oh why did they not put a return code in every function so that one would now when to poll for errors ? Oh no, just return void and force the poor programmer to poll for errors after every call.
Now that hardly seems efficient ... Maybe if I was using OpenAL directly, I could do the error checking after a block of OpenAL instructions ...

My options now ?
1 - check for errors after every OpenAL call (at least the ones with no return code)
2 - implement some mechanism to check for errors at appropriate times (a sentry class? a simple function?)

I'm following Donald Knuth's advice and keep optimization to a later stage.
After all, that's what profilers are for.

About this entry