From: Poindexter F. <sli...@gm...> - 2005-04-03 22:08:31
|
> Let's say we define EXIF_RESULT_OK, EXIF_RESULT_SOMEWHAT_OK and > EXIF_RESULT_NOT_OK. What code should libexif return if it encounters an > unknown tag or a wrong format on loading? I don't intend to suggest making things complex, but two options pop to mind that would clarify this: (1) Error handlers. Make an exif_set_handler(int error, void (*handler)(int err, char *msg)) or the like (my definition is just for example). Keep a table of error handlers. Set the default handler for every error to be the logging function currently in use. This makes EXIF_RESULT_SOMEWHAT_OK disambiguous, because by that point a developer will know what has happened, and it maintains compatibility with the current API, because by default, everything is still logged with the log handler. (2) Error stack. Make a simple struct that defines an error condition, and return a pointer to a stack of them. Yes, this means memory allocation, but it leaves it up to the developer as to what to do with it. Then it's just a matter of exif_errstack_cleanup(errstack *). This, however, leaves the current logging routines in an awkward limbo, where developers may develop around the stack, forget logging, and then, sometime down the road, someone will push for removing it from the API, because developers can already log things based on the error stack. I think that (1) is probably the best approach as (2) is horribly ugly, but I'm just throwing ideas out there. Let me know if I'm horribly off base. -- Mike "Dexter" Church |