1.10.4 Error Handling

If an API function returns a value of int type, a negative return value is an error code. A non-negative return value can hand over additional information regarding successful completion of a function call.

If an API function does not return a value of int type, the function does not support returning an error code, because error condition cannot arise within the function, or because there was such assumption when the function first appeared in the API.

If not otherwise noted in the description of an error code of an API function, returning the error code means retaining the state of QSMM library equivalent to omitting a call to the function.

Use the following API function from the header file err.h (included in qsmm.h) to get the text description of an error code.

Function: const char * qsmm_err_str (int err)

This function returns the text description of API error code err. For invalid error codes, the function returns ‘?’.

You can associate an error handler with a multinode model. The error handler receives extended information about errors in API functions that have an argument of qsmm_t type. By using the error handler, it is possible to get rid of adding extra code for checking return values of function calls to detect if they failed. See Error Handling for a Multinode Model, for information on using error handlers.