Error Handling

Error handling in Pacemaker is closely tied with libqb for logging.

Logging macros

 * crm_crit(fmt, args...)
 * crm_err(fmt, args...)
 * crm_warn(fmt, args...)
 * crm_notice(fmt, args...)
 * crm_info(fmt, args...)
 * crm_debug(fmt, args...)
 * crm_trace(fmt, args...)
 * These will log a message via libqb at the specified logging level. They can be used independently for logging purposes are via the higher-level interfaces described below.


 * crm_perror(level, fmt, args...)
 * This will log a message based on the value of the system errno, to both stderr and libqb.  is one of , etc. It should be used whenever a system error needs to be reported.

Error handling functions and macros

 * CRM_ASSERT(expr)
 * If  is false, this will call   with a "Triggered fatal assert" message (with details), then abort execution. This should be used for errors that shouldn't happen and can't be handled gracefully (for example, memory allocation failures).


 * CRM_LOG_ASSERT(expr)
 * If  is false, this will generally log a message without aborting. If the log level is below trace, it just calls   with a "Triggered assert" message (with details). If the log level is trace, and the caller is a daemon, then it will fork a child process in which to dump core, as well as logging the message. If the log level is trace, and the caller is not a daemon, then it will behave like   (i.e. log and abort). This should be used for serious errors that nonetheless require no special handling (for example, an unexpected request to close something that isn't open).


 * CRM_CHECK(expr, failed_action)
 * If  is false, behave like   (that is, log a message and dump core if requested) then perform   (which must not contain   or  ). This should be used for serious errors that can be handled, usually by returning an error status (for example, returning NULL or -1 or such if a NULL pointer is passed as an object to operate on).