Versions Compared

Key

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

...

The following code is an example of an error handler that writes errors to a filestderr. Additionally, it is used in all code snippets provided in subsequent sections to make them more concise. Please make sure this function is defined if you want to compile the code as it stands.

Code Block
languagecpp
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);
  }
}

...