[AD] Error reporting from Allegro functions

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Allegro currently provides two separate methods of indicating the precise cause of an error (usually a NULL return value). The most common method right now uses the ALLEGRO_WARN/ERROR macros. The other method uses the al_get_errno/al_set_errno functions which are basically unused. Some places, like the memfile addon, use al_set_errno with great regularity, and some places, like the image addon, provide very detailed log messages (for most errors... ironically not for the most common one of non-existent file).

So my question is... which method is preferred and to what extent? Should every "return NULL;" be accompanied with a logging macro? Should every malloc be accompanied with al_set_errno(ENOMEM); ?

Although the trace macros are attractive, I find them to be problematic as they are only enabled in debug mode. While the windows binaries we supply have the debugging versions included, as far as I can tell neither the Fedora packages nor the eventual Debian packages will have this feature. Perhaps we should move away from these macros? Also non-log error reporting is more attractive from the point of view of wrappers of Allegro.

If we do move away from macros, perhaps we should add a al_set_error_string function if al_set_errno is deemed too coarse-grained.

Anyway, just some thoughts I had after reading this thread: https://www.allegro.cc/forums/thread/612095

-SL




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/