XN_C_API XnStatus xnEnumerationErrorsToString(const XnEnumerationErrors* pErrors, XnChar* csBuffer, XnUInt32 nSize)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XnUInt32 nWritten = 0;
    csBuffer[0] = '\0';

    nRetVal = xnOSStrAppend(csBuffer, "One or more of the following nodes could not be enumerated:\n\n", nSize);
    XN_IS_STATUS_OK(nRetVal);

    nWritten = xnOSStrLen(csBuffer);

    for (XnEnumerationErrorsIterator it = xnEnumerationErrorsGetFirst(pErrors);
            xnEnumerationErrorsIteratorIsValid(it);
            it = xnEnumerationErrorsGetNext(it))
    {
        nRetVal = xnProductionNodeDescriptionToString(xnEnumerationErrorsGetCurrentDescription(it), csBuffer + nWritten, nSize - nWritten);
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = xnOSStrAppend(csBuffer, ": ", nSize);
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = xnOSStrAppend(csBuffer, xnGetStatusString(xnEnumerationErrorsGetCurrentError(it)), nSize);
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = xnOSStrAppend(csBuffer, "\n", nSize);
        XN_IS_STATUS_OK(nRetVal);

        nWritten = xnOSStrLen(csBuffer);
    }

    return (XN_STATUS_OK);
}
void ofxOpenNIContext::logErrors(xn::EnumerationErrors& rErrors) {
	for(xn::EnumerationErrors::Iterator it = rErrors.Begin(); it != rErrors.End(); ++it) {
		XnChar desc[512];
		xnProductionNodeDescriptionToString(&it.Description(), desc,512);
		printf("%s failed: %s\n", desc, xnGetStatusString(it.Error()));
	}	
}