From: Jan P. <pa...@pi...> - 2005-03-30 09:25:21
|
Hi Lutz and others, I am thinking about reasonable error handling in libexif. Lutz occasionally adds calls of exif_log() when something goes wrong. Various error conditions can be determined by constants like EXIF_LOG_CODE_CORRUPT_DATA. The bad thing is that exif_log() is then followed by return; because most functions return void. I believe it would be much better if the functions returned some completion status, like 0 for success and non-zero values like EXIF_LOG_CODE_CORRUPT_DATA when something goes wrong. Besides corrupted data, it is currently nearly impossible e.g. to see why no libexif data was obtained - it can be missing libExif APP marker, no rights to the JPEG file or even suddently missing JPEG file. The only way how to see what went wrong is actually kind of asynchronous interception of results of exif_log invocations and analysis of the results later ed = exif_data_new_from_file(fileName); if (ed == NULL) { analyze recorded exif_log information to see what failed. Most likely memory allocation problem _somewhere_ return FAILURE; } // ed is not NULL. 3 scenarios possible: // 1) evertyhing went OK // 2) no appropriate APP marker // 3) opening the file failed analyze recorded exif_log information to see if 1) is the case Changing return code from void to some enum type wouldn't cause any binary incompatibility issue - the code would be backward binary compatible. What do you think? This my proposal relates to bug #1054323 where Hans already mentioned this issue. --- Jan |