Error codes

OpenNI errors mechanism is error codes. Every function that might fail has a return value of type XnStatus. A value of XN_STATUS_OK means the function has succeeded. Any other value means some kind of failure has occurred.

For additional error information, one may use the function xnGetStatusString(), which returns a human readable description of the error, in English.

Some basic error codes can be found in file XnStatusCodes.h.

A normal usage of the error mechanism is checking if an error has occurred, and if so, print a message and close the application:

xn::Context context;
XnStatus nRetVal = context.Init();
if (nRetVal != XN_STATUS_OK)
{
printf("Failed to initialize OpenNI: %s\n", xnGetStatusString(nRetVal));
exit(-1);
}
XnStatus
XnUInt32 XnStatus
Definition XnStatus.h:34
XN_STATUS_OK
#define XN_STATUS_OK
Definition XnStatus.h:37
xnGetStatusString
XN_C_API const XnChar *XN_C_DECL xnGetStatusString(const XnStatus Status)
xn::Context
Definition XnCppWrapper.h:8594
xn::Context::Init
XnStatus Init()
Builds the context's general software environment.
Definition XnCppWrapper.h:8707