Previous: Listing a Multinode Model, Up: Multinode Model [Contents][Index]
A multinode model can have an error handler assigned to it.
The error handler is a function called in the case of a failure in any QSMM API function that takes an argument of qsmm_t
type and can return an error code of int
type.
The default error handler of a multinode model prints information on an occurred error to stderr
and calls exit(2)
.
The output consists of the name of that default error handler function followed by an indented description of an error as object content in JSON format.
If a multinode model does not have an error handler assigned (including the default error handler), or an error handler assigned to the multinode model does not terminate program execution and returns, a failed API function returns a corresponding error code.
Use the following functions to query or set an error handler for a multinode model.
This function retrieves information on an error handler assigned to a multinode model.
If func_p is not NULL
, the function sets *func_p to the pointer to the error handler function or to NULL
if the model does not have the error handler function assigned.
If param_pp is not NULL
, the function sets *param_pp to the user parameter of that error handler function.
This function assigns an error handler to a multinode model.
The argument func specifies an error handler function.
The argument paramp specifies the user parameter of this error handler function.
If func is NULL
, the model does not use an error handler.
An error handler function receives extended information on some types of errors. The header file err.h included in qsmm.h contains a declaration for the type of an error handler function. The Side API also uses this type for the error handler of an interaction side (see Error Handling for the Side API, for more information).
This is a type of an error handler function pointer with the following declaration:
typedef void (*qsmm_err_handler_func_t)( void *rez1, struct qsmm_except_s *except_p, void *paramp );
The argument except_p passes information on an occurred error. The argument paramp is a user parameter specified when setting the error handler function for a multinode model. You should not access the reserved argument rez1.
The description of a structure containing information on an occurred error is below. The header file err.h contains the declaration of this structure.
This structure is for passing information about an occurred error to an error handler function. The structure contains the following fields.
The name of a QSMM library function where the error occurred. That name might be the name of an internal library function and not an API function.
An error code to return by a failed QSMM API function after returning from the error handler function.
Extended information on the occurred error.
A list of error codes with extended error information always provided in this field is in the description of qsmm_except_u
union.
The description of a union containing extended error information depending on an error code is below. The header file err.h contains the declaration of this union.
This union contains fields corresponding to error codes that can have associated extended error information.
Extended information for error code QSMM_ERR_NOIC
.
The description of this error code is “instruction class set is empty.”
This field contains the name of an instruction class set without instruction classes.
Extended information for error code QSMM_ERR_CALLBACK
.
The description of this error code is “callback function reported an error.”
This field contains an error code returned by a callback function.
Extended information for error code QSMM_ERR_NOPROF
.
The description of this error code is “node has no probability profile specified.”
This field contains the identifier of a node without a probability profile specified.
Extended information for error code QSMM_ERR_VIOLNODE
.
The description of this error code is “change violates the parameters of an already created node.”
This field contains the identifier of a node that prevents making a change because it would violate the parameters of this node.
Extended information for error code QSMM_ERR_PRG
.
The description of this error code is “invalid program.”
This field contains a message list that hands over information on errors in an assembler program.
Extended information for error code QSMM_ERR_STORAGE
.
The description of this error code is “storage failure.”
This field refers to failed storage.
Extended information for error code QSMM_ERR_MPROF
.
The description of this error code is “too many probabilities lists in normal form.”
This field contains the maximum number of elements in the pool of probabilities lists in normal form.
Extended information for error code QSMM_ERR_NOTFOUND
.
The description of this error code is “entity not found.”
Extended information for error code QSMM_ERR_TYPE
.
The description of this error code is “invalid entity type.”
Extended information for error code QSMM_ERR_EXIST
.
The description of this error code is “entity already exists.”
Extended information for error code QSMM_ERR_OUTCOME
.
The description of this error code is “invalid instruction outcome.”
Extended information for error code QSMM_ERR_EVTHNDLR
.
The description of this error code is “event handler function reported an error.”
Extended information for error code QSMM_ERR_NOSTATE
.
The description of this error code is “not enough node states to hold the probability profile.”
Extended information for error code QSMM_ERR_NOEQCLAS
.
The description of this error code is “node classes are different.”
Extended information for error code QSMM_ERR_PROFSRCP
.
The description of this error code is “node is a probability profile source for other nodes.”
Extended information for error code QSMM_ERR_PROFSRCU
.
The description of this error code is “node is a user of a source probability profile provided by another node.”
Extended information for error code QSMM_ERR_PSUMGT1
.
The description of this error code is “sum of probabilities would exceed 1.”
Use the following function to dump the content of qsmm_except_s
structure to a stream in JSON format.
This function dumps error information in *except_p to a stream filep in JSON format as object content. The argument indent must be non-negative. It specifies left indent—the number of spaces to print at the beginning of each line of output. You should pass 0 for the reserved argument rez1.
The rest of this section describes the structures that are the fields of qsmm_except_u
union.
The header file err.h contains the declarations of those structures.
Some of them have fields of enum qsmm_lref_e
, struct qsmm_gref_s
, and struct qsmm_instr_class_s
types.
See Entity References, for the descriptions of these types.
This structure provides extended information for error code QSMM_ERR_NOTFOUND
.
The description of this error code is “entity not found.”
The structure contains the following field.
A reference to a not found entity.
This structure provides extended information for error code QSMM_ERR_TYPE
.
The description of this error code is “invalid entity type.”
The structure contains the following fields.
A required type for the entity.
A reference to the entity that has an invalid type.
This structure provides extended information for error code QSMM_ERR_EXIST
.
The description of this error code is “entity already exists.”
The structure contains the following field.
A reference to an already existing entity.
This structure provides extended information for error code QSMM_ERR_OUTCOME
.
The description of this error code is “invalid instruction outcome.”
The structure contains the following fields.
The identifier of a node invoked the assembler instruction.
An invalid instruction outcome.
The number of outcomes of the assembler instruction.
A multinode model containing a node invoked the assembler instruction.
The descriptor of an instruction class for the assembler instruction.
This structure provides extended information for error code QSMM_ERR_EVTHNDLR
.
The description of this error code is “event handler function reported an error.”
The structure contains the following fields.
A negative return value of the event handler function.
An event type passed to the event handler function—one of constants defined by the QSMM_EVT_*
macros.
The identifier of a node associated with the event. A negative value means no node association.
A reference to an entity emitting events processed by the event handler function.
This structure provides extended information for error code QSMM_ERR_NOSTATE
.
The description of this error code is “not enough node states to hold the probability profile.”
The structure contains the following fields.
The identifier of a node that has or would have the number of states less than it is necessary to hold the probability profile.
The minimum number of states the node must have to hold the probability profile.
This structure provides extended information for error code QSMM_ERR_NOEQCLAS
.
The description of this error code is “node classes are different.”
The structure contains the following fields.
The name of the first node class, that is, the first instruction class set.
The name of the second node class, that is, the second instruction class set.
The identifier of a node belonging to the first node class.
If that identifier is QSMM_SIG_INVALID
, this parameter is not applicable.
The identifier of a node belonging to the second node class.
If that identifier is QSMM_SIG_INVALID
, this parameter is not applicable.
A multinode model containing the node classes.
This structure provides extended information for error code QSMM_ERR_PROFSRCP
.
The description of this error code is “node is a probability profile source for other nodes.”
The structure contains the following fields.
The identifier of a node acting as a probability profile source for other nodes.
The number of nodes acting as probability profile users.
A multinode model containing the nodes.
This structure provides extended information for error code QSMM_ERR_PROFSRCU
.
The description of this error code is “node is a user of a source probability profile provided by another node.”
The structure contains the following fields.
The identifier of a node acting as a probability profile source.
The identifier of a node acting as a probability profile user.
A multinode model containing the nodes.
This structure provides extended information for error code QSMM_ERR_PSUMGT1
.
The description of this error code is “sum of probabilities would exceed 1.”
The structure contains the following fields.
The name of a controlled probability variable with an assigned value.
This assignment causes the sum of probabilities of case
instructions in a choice
instruction block to exceed 1.
The identifier of a node containing a state corresponding to a choice
instruction block.
The index of a node state corresponding to a choice
instruction block.
A multinode model containing the node.
Previous: Listing a Multinode Model, Up: Multinode Model [Contents][Index]