Messages

Description These functions provide support for outputting messages. The g_return family of macros (g_return_if_fail(), g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached()) should only be used for programming errors, a typical use case is checking for invalid parameters at the beginning of a public function. They should not be used if you just mean "if (error) return", they should only be used if you mean "if (bug in program) return". The program behavior is generally considered undefined after one of these checks fails. They are not intended for normal control flow, only to give a perhaps-helpful warning before giving up.

Members

Static functions

onErrorQuery
void onErrorQuery(string prgName)

Prompts the user with Exit, Halt, show Stack trace or Proceed. This function is intended to be used for debugging use only. The following example shows how it can be used together with the g_log() functions. If Exit is selected, the application terminates with a call to _exit(0). If Halt is selected, the application enters an infinite loop. The infinite loop can only be stopped by killing the application, or by setting glib_on_error_halt to FALSE (possibly via a debugger). If Stack trace is selected, g_on_error_stack_trace() is called. This invokes gdb, which attaches to the current process and shows a stack trace. The prompt is then shown again. If Proceed is selected, the function returns. This function may cause different actions on non-UNIX platforms.

onErrorStackTrace
void onErrorStackTrace(string prgName)

Invokes gdb, which attaches to the current process and shows a stack trace. Called by g_on_error_query() when the Stack trace option is selected. This function may cause different actions on non-UNIX platforms.

setPrintHandler
GPrintFunc setPrintHandler(GPrintFunc func)

Sets the print handler. Any messages passed to g_print() will be output via the new handler. The default handler simply outputs the message to stdout. By providing your own handler you can redirect the output, to a GTK+ widget or a log file for example.

setPrinterrHandler
GPrintFunc setPrinterrHandler(GPrintFunc func)

Sets the handler for printing error messages. Any messages passed to g_printerr() will be output via the new handler. The default handler simply outputs the message to stderr. By providing your own handler you can redirect the output, to a GTK+ widget or a log file for example.

Meta