Semi-determinism in Exempi
pipian at pipian.com
Tue Apr 8 22:24:46 PDT 2008
In the process of fiddling a bit more with Exempi, I've worked around
a minor bug that I'm still trying to fix (I'll send a patch when I
can), and discovered a rather unpleasant side-effect of Exempi's
exception handling of the internal C++ code: Many functions that
return boolean values will return false if the main function returns
false AND when an exception is caught. This in and of itself would
not be a problem, but there is no way to determine when a genuine
error has occurred and when the function is returning false, as the
error code is not reset between function calls.
For example, if there is an error in obtaining a property value with
xmp_get_property(), it is indistinguishable from when no property is
found, as there is no way to know whether or not xmp_get_error() was
set during xmp_get_property(). This makes it difficult to write unit
tests when expecting no property to be found, as there is no way to
ensure that an error did not occur when reading the property.
I thus propose that exempi add a new error code XMPErr_OK to which the
error variable is set at the beginning of each function. This way, it
is possible to determine if a genuine error has occurred or whether
the function is merely returning false.
More information about the Exempi-devel