Semi-determinism in Exempi
hub at figuiere.net
Wed Apr 23 21:34:44 PDT 2008
Sorry I was meant to reply to this earlier and got sidetracked...
On Wed, 2008-04-09 at 01:24 -0400, Pipian wrote:
> 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
> 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.
For individual cases like that it is a bug. I'll recheck the code and
make sure it does it properly by resetting the error code. It is already
supposed to be 0 if there is no error. I'll see if this can be improved.
Also I have to make it thread safe, it isn't currently, ie if called
from different thread the error code may be overridden. Having it
per-thread should help.
More information about the Exempi-devel