You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Most LMX API functions return status information LMX_STATUS that indicates the success or failure of the requested operation. You should review this information to make problem identification easier.

The following code is an example of an error handler that writes errors to a file:

 

 

 

LMX_HANDLE h;

void exit_on_error(LMX_STATUS s) {
  if (s != LMX_SUCCESS) {
    if (h != NULL) {
      fprintf(stderr, "%s\n", LMX_GetErrorMessage(h));
      LMX_Free(h); // Release memory allocated by LM-X 
    } else {
      fprintf(stderr, "%s\n", LMX_GetErrorMessageSimple(s));
    }
    fflush(stderr);
    exit(1);
  }

In case of faillure, that is to say a LMX_STATUS different from LMX_SUCCESS, this helper will display the corresponding error. If the handler is null, it will simply display the error name.

 

 

 

 

  • No labels