4
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>GError</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7
7
<link rel="home" href="index.html" title="GConf Reference Manual">
8
8
<link rel="up" href="ch01.html" title="Using the GConf library">
9
9
<link rel="prev" href="gconf-gconf-engine.html" title="GConfEngine">
38
38
<div class="refsynopsisdiv">
39
39
<a name="gconf-gconf-error.synopsis"></a><h2>Synopsis</h2>
40
40
<pre class="synopsis">enum <a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError">GConfError</a>;
41
<a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="returnvalue">GError</span></a> * <a class="link" href="gconf-gconf-error.html#gconf-error-new" title="gconf_error_new ()">gconf_error_new</a> (<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
42
<em class="parameter"><code>const <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *format</code></em>,
41
<span class="returnvalue">GError</span> * <a class="link" href="gconf-gconf-error.html#gconf-error-new" title="gconf_error_new ()">gconf_error_new</a> (<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
42
<em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
43
43
<em class="parameter"><code>...</code></em>);
44
<a href="http://library.gnome.org/devel/glib/unstable/glib-Quarks.html#GQuark"><span class="returnvalue">GQuark</span></a> <a class="link" href="gconf-gconf-error.html#gconf-error-quark" title="gconf_error_quark ()">gconf_error_quark</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
45
<span class="returnvalue">void</span> <a class="link" href="gconf-gconf-error.html#gconf-set-error" title="gconf_set_error ()">gconf_set_error</a> (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **err</code></em>,
44
<span class="returnvalue">GQuark</span> <a class="link" href="gconf-gconf-error.html#gconf-error-quark" title="gconf_error_quark ()">gconf_error_quark</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
45
<span class="returnvalue">void</span> <a class="link" href="gconf-gconf-error.html#gconf-set-error" title="gconf_set_error ()">gconf_set_error</a> (<em class="parameter"><code><span class="type">GError</span> **err</code></em>,
46
46
<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
47
<em class="parameter"><code>const <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *format</code></em>,
47
<em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
48
48
<em class="parameter"><code>...</code></em>);
49
<a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="returnvalue">GError</span></a> * <a class="link" href="gconf-gconf-error.html#gconf-compose-errors" title="gconf_compose_errors ()">gconf_compose_errors</a> (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> *err1</code></em>,
50
<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> *err2</code></em>);
49
<span class="returnvalue">GError</span> * <a class="link" href="gconf-gconf-error.html#gconf-compose-errors" title="gconf_compose_errors ()">gconf_compose_errors</a> (<em class="parameter"><code><span class="type">GError</span> *err1</code></em>,
50
<em class="parameter"><code><span class="type">GError</span> *err2</code></em>);
53
53
<div class="refsect1">
54
54
<a name="gconf-gconf-error.description"></a><h2>Description</h2>
56
The <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> object is used to report errors that occur in GConf
56
The <span class="type">GError</span> object is used to report errors that occur in GConf
57
57
library routines. All functions that report errors work the same way:
59
59
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
60
60
<li class="listitem"><p>
61
The last argument to the function is a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>**, a pointer to a
62
location where a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>* can be placed.
61
The last argument to the function is a <span class="type">GError</span>**, a pointer to a
62
location where a <span class="type">GError</span>* can be placed.
64
64
<li class="listitem"><p>
65
65
This last argument may be <span class="symbol">NULL</span>, in which case no
68
68
<li class="listitem"><p>
69
69
If non-<span class="symbol">NULL</span>, the argument should be the address of a
70
<a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>* variable, which should be initialized to
70
<span class="type">GError</span>* variable, which should be initialized to
71
71
<span class="symbol">NULL</span>.
73
73
<li class="listitem"><p>
74
If an error occurs, a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> will be allocated and placed in the
75
return location; the caller must free the <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> with
76
<a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#g-error-free"><code class="function">g_error_free()</code></a>. If no error occurs, the return location will be
74
If an error occurs, a <span class="type">GError</span> will be allocated and placed in the
75
return location; the caller must free the <span class="type">GError</span> with
76
<code class="function">g_error_free()</code>. If no error occurs, the return location will be
77
77
left untouched. That is, the test <code class="literal">error != NULL</code>
78
78
should always be a reliable indicator of whether the operation failed.
86
86
on success. In some cases, a <span class="symbol">NULL</span> return value
87
87
indicates failure. Either way, if the return value indicates failure
88
88
and you passed a non-<span class="symbol">NULL</span> value for the last argument
89
to the function, a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> will be returned. If the return value
90
indicates success, then a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> will never be returned. These
89
to the function, a <span class="type">GError</span> will be returned. If the return value
90
indicates success, then a <span class="type">GError</span> will never be returned. These
91
91
relationships are guaranteed; that is, you can reliably use the return
92
value to decide whether a <a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> was placed in the return
92
value to decide whether a <span class="type">GError</span> was placed in the return
93
93
location. If a function does <span class="emphasis"><em>not</em></span> indicate
94
94
success/failure by return value, you must check whether the
95
<a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> is <span class="symbol">NULL</span> to detect errors.
95
<span class="type">GError</span> is <span class="symbol">NULL</span> to detect errors.
98
98
Here's a short error handling example:
236
236
<div class="refsect2">
237
237
<a name="gconf-error-new"></a><h3>gconf_error_new ()</h3>
238
<pre class="programlisting"><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="returnvalue">GError</span></a> * gconf_error_new (<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
239
<em class="parameter"><code>const <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *format</code></em>,
238
<pre class="programlisting"><span class="returnvalue">GError</span> * gconf_error_new (<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
239
<em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
240
240
<em class="parameter"><code>...</code></em>);</pre>
242
242
Creates a new error. Normally the GConf library does this, but you
266
266
<div class="refsect2">
267
267
<a name="gconf-error-quark"></a><h3>gconf_error_quark ()</h3>
268
<pre class="programlisting"><a href="http://library.gnome.org/devel/glib/unstable/glib-Quarks.html#GQuark"><span class="returnvalue">GQuark</span></a> gconf_error_quark (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
268
<pre class="programlisting"><span class="returnvalue">GQuark</span> gconf_error_quark (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
270
Converts the string 'gconf-error-quark' to a <a href="http://library.gnome.org/devel/glib/unstable/glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> and returns the value.
270
Converts the string 'gconf-error-quark' to a <span class="type">GQuark</span> and returns the value.
272
272
<div class="variablelist"><table border="0">
273
273
<col align="left" valign="top">
275
275
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
276
<td>the <a href="http://library.gnome.org/devel/glib/unstable/glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> representing the string.</td>
276
<td>the <span class="type">GQuark</span> representing the string.</td>
281
281
<div class="refsect2">
282
282
<a name="gconf-set-error"></a><h3>gconf_set_error ()</h3>
283
<pre class="programlisting"><span class="returnvalue">void</span> gconf_set_error (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **err</code></em>,
283
<pre class="programlisting"><span class="returnvalue">void</span> gconf_set_error (<em class="parameter"><code><span class="type">GError</span> **err</code></em>,
284
284
<em class="parameter"><code><a class="link" href="gconf-gconf-error.html#GConfError" title="enum GConfError"><span class="type">GConfError</span></a> en</code></em>,
285
<em class="parameter"><code>const <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *format</code></em>,
285
<em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
286
286
<em class="parameter"><code>...</code></em>);</pre>
288
288
Internal function.
292
292
<div class="refsect2">
293
293
<a name="gconf-compose-errors"></a><h3>gconf_compose_errors ()</h3>
294
<pre class="programlisting"><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="returnvalue">GError</span></a> * gconf_compose_errors (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> *err1</code></em>,
295
<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> *err2</code></em>);</pre>
294
<pre class="programlisting"><span class="returnvalue">GError</span> * gconf_compose_errors (<em class="parameter"><code><span class="type">GError</span> *err1</code></em>,
295
<em class="parameter"><code><span class="type">GError</span> *err2</code></em>);</pre>
297
297
Internal function.