TOC PREV NEXT INDEX

Return Status

Status codes

Most routines return a status code:
Status code
Value
Meaning
OM_STAT_SUCCESS
1
The routine completed successfully.
OM_STAT_UNDEF
0
The routine attempted to get a value from an object that has no defined value.
OM_STAT_ERROR
-1
The routine failed for any other reason.

Error messages

Some routines, when they fail with a status of OM_STAT_ERROR, generate error messages containing diagnostic information. These messages are printed to stderr. To suppress errors printed during a routine, you can "squash" errors for a duration of your code. Typically you only want to squash errors for one routine at a time. You can do this using the macro ERRsquash_start before the routine and ERRsquash_end after the routine. For example:

ERRsquash_start(); // begin suppressing errors
stat = OMget_int_val(obj_id, &val);
ERRsquash_end();
// end suppressing errors

Routines returning OMobj_id

Several routines, like OMfind_subobj, return an object id. If the routine fails, the returned value is OMnull_obj. You can test for this value with the routine OMis_null_obj. The following example attempts to get the object id of subobject x:

OMobj_id parent_id, x_id;
...
x_id = OMfind_subobj(parent_id, OMstr_to_name("x"),
OM_OBJ_RW);
if (OMis_null_obj(x_id))
printf("Error searching for x\n");


TOC PREV NEXT INDEX