The LMX_GetErrorMessage function retrieves a NULL-terminated string for the last LM-X function call that occurred.

Prototype

const char * LMX_GetErrorMessage
(
   LMX_HANDLE LmxHandle
);

Parameters

LmxHandle
[in] LM-X handle.

Return values

The return value is a pointer to a NULL-terminated string that contains descriptive text for the error code.

Remarks

This function returns a detailed message for the last LM-X function call that occurred.

The message includes the feature name, internal error code, and context-specific error whenever relevant. Typically, the context-specific error and internal error code are used only by X-Formation for support purposes.

Example

LM-X Error: (Internal: 33 Feature: f1)
Feature not found
For further information go to http://www.x-formation.com

The pointer returned is guaranteed to be valid only until the next function call that uses the LmxHandle parameter. Accordingly, it is recommended not to store the pointer.

Note: You cannot call LMX_GetErrorMessage from the heartbeat callback functions (see Heartbeats and LMX_SetOption). Instead, you may call LMX_GetErrorMessageSimple.

The following is a basic example of using LMX_GetErrorMessage, which returns a detailed error message for the last LM-X function call that occurred.

#include <lmx.h>
#include <stdio.h>

LMX_HANDLE h;

int main() 
{
  LMX_FEATURE_INFO FI;

  exit_on_error(LMX_Init(&h));
  if (LMX_GetFeatureInfo(h,"nonExistingFeature", &FI) != LMX_SUCCESS) 
  {
    if (h != NULL) 
    {
      fprintf(stderr, "%s\n", LMX_GetErrorMessage(h));
      LMX_Free(h);
    } 
    else 
    {
      fprintf(stderr, "%s\n", LMX_GetErrorMessageSimple(s));
	  fflush(stderr);
      return 1;
	}
  }
  return 0;
}