Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
const char * LMX_GetErrorMessage
(
   LMX_HANDLE LmxHandle
);

Parameters

LmxHandle
[in/out] LM-X handle.

Return values

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

...

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

...

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

The following example shows an error caused by checking out a non-existent feature. It also shows information contained in the LMX_ERROR_INFO structure and calls an exit() functionis a basic example of using LMX_GetErrorMessage, which returns a detailed error message for the last LM-X function call that occurred.

Code Block
languagecpp
#include <lmx.h>
#include <stdio.h>

LMX_HANDLE h;

int main()  
{
  LMX_FEATURE_STATUSINFO sFI;
  
  exit_on_error(LMX_Init(&h));
  if ((s = LMX_CheckoutGetFeatureInfo(h,"nonExistingFeature", 1, 1, 1)&FI) != LMX_SUCCESS) 
  {
    const LMX_ERROR_INFO* ePtr = LMX_GetError(h);
if (h != NULL) 
    {
      fprintf(stderr, "Status: %s\n", LMX_GetErrorMessageSimpleGetErrorMessage(sh));
    fprintf(stderr, "Line: %d\n", ePtr->nInternal LMX_Free(h);
    fprintf(stderr, "Error code: %d\n", ePtr->nContext);} 
    else 
    fprintf(stderr, "Description: %s\n", ePtr->szDescription);
 {
      fprintf(stderr, "Feature: %s\n", ePtr->szFeatureNameLMX_GetErrorMessageSimple(s));
	    fflush(stderr);
    exit(1)  return 1;
	}
  }
  return return 0;
}