Error Handling

Upon return, all routines return an integer value. In most cases the value zero (MIMER_SUCCESS) is used to indicates success. In some cases a positive value is used to indicate success with additional information. Negative values always indicate an error condition. The negative values are standard Mimer SQL error codes, which are listed in Return Codes.

Errors between -24000 and -24299 are specific to Mimer API, where errors in the -24100 to -24199 range occur because of programming mistakes. Errors in the -24200 to -24299 range are of internal nature caused by system problems.

The Mimer API specific return codes are listed in Mimer SQL C API Return Codes. The acronyms for the Mimer API specific return codes can be found in the mimerrors.h header file.

The macro MIMER_SUCCEEDED may be used to detect a call which has either succeeded, or succeeded with additional information (a positive value). Negating this macro may be used to detect an error.

The error condition MIMER_SEQUENCE_ERROR has a special meaning. It will be returned when an illegal call has been made. The Mimer API will enforce a strict sequence of allowed calls. For example, MimerGetString may not be called before MimerFetch has been called. MIMER_SEQUENCE_ERROR is returned when illegal sequences of calls are detected.

Error Handling Example

The below example function shows how a function uses the return value from a Mimer API function call to determine success or failure.


* Function which executes the statement OUR_STATEMENT


* On failure, the error code is written to stdout.


#include "mimerapi.h"

int example1(MimerSession session)


 int32_t err, end_err=MIMER_SUCCESS;

 MimerStatement statement;


 err = MimerBeginStatement(session, L"OUR_STATEMENT", 0, &statement);

 if (MIMER_SUCCEEDED(err)) {

   err = MimerExecute(statement);

   end_err = MimerEndStatement(&statement);


 if (!MIMER_SUCCEEDED(err) || !MIMER_SUCCEEDED(end_err)) {

printf("Error %d, end error %d.\n", err, end_err);