is the standard error reporting mechanism for GLib-using code, and can be thought of as a C implementation of an .
Any kind of runtime failure (anything which is not a GError** parameter in the function, and setting a useful and relevant GError describing the failure, before returning from the function. Programmer errors must not be handled using GError: use assertions, pre-conditions or post-conditions instead.) must be handled by including a
GError should be used in preference to a simple return code, as it can convey more information, and is also supported by all GLib tools. For example,will automatically detect all GError parameters so that they can be converted to exceptions in other languages.
Printing warnings to the console must not be done in library code: use a GError, and the calling code can propagate it further upwards, decide to handle it, or decide to print it to the console. Ideally, the only code which prints to the console will be top-level application code, and not library code.
Any function call which can take a GError**, should take such a parameter, and the returned GError should be handled appropriately. There are very few situations where ignoring a potential error by passing NULL to a GError** parameter is acceptable.
The GLib API documentation contains a.
This work is licensed under a.
As a special exception, the copyright holders give you permission to copy, modify, and distribute the example code contained in this document under the terms of your choosing, without restriction.
Got a comment? Spotted an error? Found the instructions unclear? Send feedback about this page.