<refentry id="glib-Error-Reporting">
<refmeta>
<refentrytitle>Error Reporting</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Error Reporting</refname><refpurpose>a system for reporting errors.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>

#include &lt;glib.h&gt;


struct      <link linkend="GError">GError</link>;
<link linkend="GError">GError</link>*     <link linkend="g-error-new">g_error_new</link>                     (<link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *format,
                                             ...);
<link linkend="GError">GError</link>*     <link linkend="g-error-new-literal">g_error_new_literal</link>             (<link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *message);
void        <link linkend="g-error-free">g_error_free</link>                    (<link linkend="GError">GError</link> *error);
<link linkend="GError">GError</link>*     <link linkend="g-error-copy">g_error_copy</link>                    (const <link linkend="GError">GError</link> *error);
<link linkend="gboolean">gboolean</link>    <link linkend="g-error-matches">g_error_matches</link>                 (const <link linkend="GError">GError</link> *error,
                                             <link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code);
void        <link linkend="g-set-error">g_set_error</link>                     (<link linkend="GError">GError</link> **err,
                                             <link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *format,
                                             ...);
void        <link linkend="g-propagate-error">g_propagate_error</link>               (<link linkend="GError">GError</link> **dest,
                                             <link linkend="GError">GError</link> *src);
void        <link linkend="g-clear-error">g_clear_error</link>                   (<link linkend="GError">GError</link> **err);
</synopsis>
</refsynopsisdiv>





<refsect1>
<title>Description</title>

<para>
GLib provides a standard method of reporting errors from a called function to
the calling code. (This is the same problem solved by exceptions in other
languages.) It's important to understand that this method is both a
<emphasis>data type</emphasis> (the <link linkend="GError">GError</link> object) and a <emphasis>set of
rules.</emphasis> If you use <link linkend="GError">GError</link> incorrectly, then your code will not
properly interoperate with other code that uses <link linkend="GError">GError</link>, and users of your API
will probably get confused.
</para>

<para>
First and foremost: <emphasis><link linkend="GError">GError</link> should only be used to report
recoverable runtime errors, never to report programming errors.</emphasis> If
the programmer has screwed up, then you should use <link linkend="g-warning">g_warning</link>(),
<link linkend="g-return-if-fail">g_return_if_fail</link>(), <link linkend="g-assert">g_assert</link>(), <link linkend="g-error">g_error</link>(), or some similar facility.
(Incidentally, remember that the <link linkend="g-error">g_error</link>() function should
<emphasis>only</emphasis> be used for programming errors, it should not be used
to print any error reportable via <link linkend="GError">GError</link>.)
</para>

<para>
Examples of recoverable runtime errors are "file not found" or "failed to parse
input." Examples of programming errors are "NULL passed to <link linkend="strcmp">strcmp</link>()" or
"attempted to free the same pointer twice." These two kinds of errors are
fundamentally different: runtime errors should be handled or reported to the
user, programming errors should be eliminated by fixing the bug in the program.
This is why most functions in GLib and GTK+ do not use the <link linkend="GError">GError</link> facility.
</para>

<para>
Functions that can fail take a return location for a <link linkend="GError">GError</link> as their last argument. 
For example:
<informalexample><programlisting>
gchar* g_file_get_contents (const gchar *filename, GError **error);
</programlisting></informalexample>
If you pass a non-<literal>NULL</literal> value for the <literal>error</literal> argument, it should 
point to a location where an error can be placed. For example:
<informalexample><programlisting>
gchar *contents;
GError *err = NULL;
contents = g_file_get_contents ("foo.txt", &amp;err);
g_assert ((contents == NULL && err != NULL) || (contents != NULL && err == NULL));
if (err != NULL)
  {
    /* Report error to user, and free error */
    g_assert (contents == NULL);
    fprintf (stderr, "Unable to read file: <literal>s</literal>\n", err->message);
    g_error_free (err);
  } 
else
  {
    /* Use file contents */
    g_assert (contents != NULL);
  }
</programlisting></informalexample>
Note that <literal>err != NULL</literal> in this example is a
<emphasis>reliable</emphasis> indicator of whether
<link linkend="g-file-get-contents">g_file_get_contents</link>() failed. Also, <link linkend="g-file-get-contents">g_file_get_contents</link>() uses the
convention that a <literal>NULL</literal> return value means an error occurred (but not
all functions use this convention).
</para>

<para>
Because <link linkend="g-file-get-contents">g_file_get_contents</link>() returns <literal>NULL</literal> on failure, if you are only
interested in whether it failed and don't need to display an error message, you
can pass <literal>NULL</literal> for the <literal>error</literal> argument:
<informalexample><programlisting>
contents = g_file_get_contents ("foo.txt", NULL); /* ignore errors */
if (contents != NULL)
  /* no error occurred */ ;
else
  /* error */ ;
</programlisting></informalexample>
</para>

<para>
The <link linkend="GError">GError</link> object contains three fields: <literal>domain</literal> indicates
the module the error-reporting function is located in, <literal>code</literal>
indicates the specific error that occurred, and <literal>message</literal> is a
user-readable error message with as many details as possible. Several functions
are provided to deal with an error received from a called function:
<link linkend="g-error-matches">g_error_matches</link>() returns <literal>TRUE</literal> if the error matches a given domain and code,
<link linkend="g-propagate-error">g_propagate_error</link>() copies an error into an error location (so the calling
function will receive it), and <link linkend="g-clear-error">g_clear_error</link>() clears an error location by
freeing the error and resetting the location to <literal>NULL</literal>. To display an error to the
user, simply display <literal>error-&gt;message</literal>, perhaps along with
additional context known only to the calling function (the file being opened, or
whatever -- though in the <link linkend="g-file-get-contents">g_file_get_contents</link>() case,
<literal>error-&gt;message</literal> already contains a filename).
</para>

<para>
When implementing a function that can report errors, the basic tool is
<link linkend="g-set-error">g_set_error</link>(). Typically, if a fatal error occurs you want to <link linkend="g-set-error">g_set_error</link>(),
then return immediately. <link linkend="g-set-error">g_set_error</link>() does nothing if the error location passed
to it is <literal>NULL</literal>. Here's an example:
<informalexample><programlisting>
gint
foo_open_file (GError **error)
{
  gint fd;

  fd = open ("file.txt", O_RDONLY);

  if (fd < 0)
    {
      g_set_error (error,
                   FOO_ERROR,                 /* error domain */
                   FOO_ERROR_BLAH,            /* error code */
                   "Failed to open file: <literal>s</literal>", /* error message format string */
                   g_strerror (errno));
      return -1;
    }
  else
    return fd;
}
</programlisting></informalexample>
</para>

<para>
Things are somewhat more complicated if you yourself call another function that
can report a <link linkend="GError">GError</link>. If the sub-function indicates fatal errors in some way
other than reporting a <link linkend="GError">GError</link>, such as by returning <literal>TRUE</literal> on success, you can
simply do the following:
<informalexample><programlisting>
gboolean
my_function_that_can_fail (GError **err)
{
  g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

  if (!sub_function_that_can_fail (err))
    {
       /* assert that error was set by the sub-function */
       g_assert (err == NULL || *err != NULL);  
       return FALSE;
    }

  /* otherwise continue, no error occurred */
  g_assert (err == NULL || *err == NULL);
}
</programlisting></informalexample>
</para>

<para>
If the sub-function does not indicate errors other than by reporting a <link linkend="GError">GError</link>, 
you need to create a temporary <link linkend="GError">GError</link> since the passed-in one may be <literal>NULL</literal>.
<link linkend="g-propagate-error">g_propagate_error</link>() is intended for use in this case.
<informalexample><programlisting>
gboolean
my_function_that_can_fail (GError **err)
{
  GError *tmp_error;

  g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

  tmp_error = NULL;
  sub_function_that_can_fail (&amp;tmp_error);

  if (tmp_error != NULL)
    {
       /* store tmp_error in err, if err != NULL,
        * otherwise call g_error_free(<!>) on tmp_error 
        */
       g_propagate_error (err, tmp_error);
       return FALSE;
    }

  /* otherwise continue, no error occurred */
}
</programlisting></informalexample>
</para>

<para>
Error pileups are always a bug. For example, this code is incorrect:
<informalexample><programlisting>
gboolean
my_function_that_can_fail (GError **err)
{
  GError *tmp_error;

  g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

  tmp_error = NULL;
  sub_function_that_can_fail (&amp;tmp_error);
  other_function_that_can_fail (&amp;tmp_error);

  if (tmp_error != NULL)
    {
       g_propagate_error (err, tmp_error);
       return FALSE;
    }
}
</programlisting></informalexample>
<literal>tmp_error</literal> should be checked immediately after
<function><link linkend="sub-function-that-can-fail">sub_function_that_can_fail</link>()</function>, and either cleared or propagated upward.  The rule
is: <emphasis>after each error, you must either handle the error, or return it to the
calling function</emphasis>.  Note that passing <literal>NULL</literal> for the error location is the
equivalent of handling an error by always doing nothing about it. So the
following code is fine, assuming errors in <function><link linkend="sub-function-that-can-fail">sub_function_that_can_fail</link>()</function> are not
fatal to <function><link linkend="my-function-that-can-fail">my_function_that_can_fail</link>()</function>:
<informalexample><programlisting>
gboolean
my_function_that_can_fail (GError **err)
{
  GError *tmp_error;

  g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

  sub_function_that_can_fail (NULL); /* ignore errors */

  tmp_error = NULL;
  other_function_that_can_fail (&amp;tmp_error);

  if (tmp_error != NULL)
    {
       g_propagate_error (err, tmp_error);
       return FALSE;
    }
}
</programlisting></informalexample>
</para>

<para>
Note that passing <literal>NULL</literal> for the error location <emphasis>ignores</emphasis>
errors; it's equivalent to <literal>try { <link linkend="sub-function-that-can-fail">sub_function_that_can_fail</link>(); } catch
(...) {}</literal> in C++. It does <emphasis>not</emphasis> mean to leave errors
unhandled; it means to handle them by doing nothing.
</para>

<para>
Error domains and codes are conventionally named as follows:
<itemizedlist>
<listitem>
<para>
The error domain is called
<literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR</literal>, for example
<literal>G_EXEC_ERROR</literal> or <literal>G_THREAD_ERROR</literal>.
</para>
</listitem>
<listitem>
<para>
The error codes are in an enumeration called 
<literal>&lt;Namespace&gt;_&lt;Module&gt;_Error</literal>; for example,
<link linkend="GThreadError">GThreadError</link> or <link linkend="GSpawnError">GSpawnError</link>.
</para>
</listitem>
<listitem>
<para>
Members of the error code enumeration are called <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_&lt;CODE&gt;</literal>, for example <literal>G_SPAWN_ERROR_FORK</literal> or <literal>G_THREAD_ERROR_AGAIN</literal>. 
</para>
</listitem>
<listitem>
<para>
If there's a "generic" or "unknown" error code for unrecoverable errors it
doesn't make sense to distinguish with specific codes, it should be called 
<literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_FAILED</literal>, for 
example <literal>G_SPAWN_ERROR_FAILED</literal> or <literal>G_THREAD_ERROR_FAILED</literal>.
</para>
</listitem>
</itemizedlist>
</para>

<para>
Summary of rules for use of <link linkend="GError">GError</link>:
      <itemizedlist>
	<listitem>
	  <para>
           Do not report programming errors via <link linkend="GError">GError</link>.
	  </para>
	</listitem>

      <listitem>
        <para>
          The last argument of a function that returns an error should be a
          location where a <link linkend="GError">GError</link> can be placed (i.e. "<link linkend="GError">GError</link>** error").  If
          <link linkend="GError">GError</link> is used with varargs, the <link linkend="GError">GError</link>** should be the last
          argument before the "...".
        </para>
      </listitem>

      <listitem>
        <para>
          The caller may pass <literal>NULL</literal> for the <link linkend="GError">GError</link>** if they are not interested
          in details of the exact error that occurred.
        </para>
      </listitem>

	<listitem>
	  <para>
           If <literal>NULL</literal> is passed for the <link linkend="GError">GError</link>** argument, then errors should 
           not be returned to the caller, but your function should still 
           abort and return if an error occurs. That is, control flow should
           not be affected by whether the caller wants to get a <link linkend="GError">GError</link>.
	  </para>
	</listitem>

      <listitem>
        <para>
          If a <link linkend="GError">GError</link> is reported, then your function by definition  
          <emphasis>had a fatal failure and did not complete whatever it was supposed
            to do</emphasis>. If the failure was not fatal, then you handled it
          and you should not report it. If it was fatal, then you must report it 
          and discontinue whatever you were doing immediately.
        </para>
      </listitem>

	<listitem>
	  <para>
          A <link linkend="GError">GError</link>* must be initialized to <literal>NULL</literal> before passing its address to
          a function that can report errors.
	  </para>
	</listitem>

	<listitem>
	  <para>
          "Piling up" errors is always a bug. That is, if you assign a new
          <link linkend="GError">GError</link> to a <link linkend="GError">GError</link>* that is non-<literal>NULL</literal>, thus overwriting the previous
          error, it indicates that you should have aborted the operation instead
          of continuing. If you were able to continue, you should have cleared
          the previous error with <link linkend="g-clear-error">g_clear_error</link>(). <link linkend="g-set-error">g_set_error</link>() will complain
          if you pile up errors.
	  </para>
	</listitem>


	<listitem>
	  <para>
          By convention, if you return a boolean value indicating success 
          then <literal>TRUE</literal> means success and <literal>FALSE</literal> means failure. If <literal>FALSE</literal> is returned,
          the error <emphasis>must</emphasis> be set to a non-<literal>NULL</literal> value. 
        </para>
	</listitem>


	<listitem>
	  <para>
          A <literal>NULL</literal> return value is also frequently used to mean that an error
          occurred.  You should make clear in your documentation whether <literal>NULL</literal> is
          a valid return value in non-error cases; if <literal>NULL</literal> is a valid value,
          then users must check whether an error was returned to see if the
          function succeeded.
	  </para>
	</listitem>

	<listitem>
	  <para>
          When implementing a function that can report errors, you may want to
          add a check at the top of your function that the error return location
          is either <literal>NULL</literal> or contains a <literal>NULL</literal> error
          (e.g. <literal>g_return_if_fail (error == NULL || *error ==
          NULL);</literal>).
	  </para>
	</listitem>


</itemizedlist>
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="GError">struct GError</title>
<programlisting>struct GError
{
  GQuark       domain;
  gint         code;
  gchar       *message;
};
</programlisting>
<para>
The <structname>GError</structname> structure contains 
information about an error that has occurred.
</para><informaltable pgwide="1" frame="none" role="struct">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row>
<entry><link linkend="GQuark">GQuark</link> <structfield>domain</structfield></entry>
<entry>error domain, e.g. <link linkend="G-FILE-ERROR-CAPS">G_FILE_ERROR</link>.
</entry>
</row>
<row>
<entry><link linkend="gint">gint</link> <structfield>code</structfield></entry>
<entry>error code, e.g. <literal>G_FILE_ERROR_NOENT</literal>.
</entry>
</row>
<row>
<entry><link linkend="gchar">gchar</link> *<structfield>message</structfield></entry>
<entry>human-readable informative error message.

</entry>
</row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-error-new">g_error_new ()</title>
<programlisting><link linkend="GError">GError</link>*     g_error_new                     (<link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *format,
                                             ...);</programlisting>
<para>
Creates a new <link linkend="GError">GError</link> with the given <parameter>domain</parameter> and <parameter>code</parameter>,
and a message formatted with <parameter>format</parameter>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>domain</parameter>&nbsp;:</entry>
<entry> error domain 
</entry></row>
<row><entry align="right"><parameter>code</parameter>&nbsp;:</entry>
<entry> error code
</entry></row>
<row><entry align="right"><parameter>format</parameter>&nbsp;:</entry>
<entry> <function>printf()</function>-style format for error message
</entry></row>
<row><entry align="right"><parameter>...</parameter>&nbsp;:</entry>
<entry> parameters for message format
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a new <link linkend="GError">GError</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-error-new-literal">g_error_new_literal ()</title>
<programlisting><link linkend="GError">GError</link>*     g_error_new_literal             (<link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *message);</programlisting>
<para>
Creates a new <link linkend="GError">GError</link>; unlike <link linkend="g-error-new">g_error_new</link>(), <parameter>message</parameter> is not
a <function>printf()</function>-style format string. Use this 
function if <parameter>message</parameter> contains text you don't have control over, 
that could include <function>printf()</function> escape sequences.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>domain</parameter>&nbsp;:</entry>
<entry> error domain
</entry></row>
<row><entry align="right"><parameter>code</parameter>&nbsp;:</entry>
<entry> error code
</entry></row>
<row><entry align="right"><parameter>message</parameter>&nbsp;:</entry>
<entry> error message
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a new <link linkend="GError">GError</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-error-free">g_error_free ()</title>
<programlisting>void        g_error_free                    (<link linkend="GError">GError</link> *error);</programlisting>
<para>
Frees a <link linkend="GError">GError</link> and associated resources.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>error</parameter>&nbsp;:</entry>
<entry> a <link linkend="GError">GError</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-error-copy">g_error_copy ()</title>
<programlisting><link linkend="GError">GError</link>*     g_error_copy                    (const <link linkend="GError">GError</link> *error);</programlisting>
<para>
Makes a copy of <parameter>error</parameter>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>error</parameter>&nbsp;:</entry>
<entry> a <link linkend="GError">GError</link>
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a new <link linkend="GError">GError</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-error-matches">g_error_matches ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    g_error_matches                 (const <link linkend="GError">GError</link> *error,
                                             <link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code);</programlisting>
<para>
Returns <literal>TRUE</literal> if <parameter>error</parameter> matches <parameter>domain</parameter> and <parameter>code</parameter>, <literal>FALSE</literal>
otherwise.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>error</parameter>&nbsp;:</entry>
<entry> a <link linkend="GError">GError</link>
</entry></row>
<row><entry align="right"><parameter>domain</parameter>&nbsp;:</entry>
<entry> an error domain
</entry></row>
<row><entry align="right"><parameter>code</parameter>&nbsp;:</entry>
<entry> an error code
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> whether <parameter>error</parameter> has <parameter>domain</parameter> and <parameter>code</parameter>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-set-error">g_set_error ()</title>
<programlisting>void        g_set_error                     (<link linkend="GError">GError</link> **err,
                                             <link linkend="GQuark">GQuark</link> domain,
                                             <link linkend="gint">gint</link> code,
                                             const <link linkend="gchar">gchar</link> *format,
                                             ...);</programlisting>
<para>
Does nothing if <parameter>err</parameter> is <literal>NULL</literal>; if <parameter>err</parameter> is non-<literal>NULL</literal>, then *<parameter>err</parameter> must
be <literal>NULL</literal>. A new <link linkend="GError">GError</link> is created and assigned to *<parameter>err</parameter>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>err</parameter>&nbsp;:</entry>
<entry> a return location for a <link linkend="GError">GError</link>, or <literal>NULL</literal>
</entry></row>
<row><entry align="right"><parameter>domain</parameter>&nbsp;:</entry>
<entry> error domain
</entry></row>
<row><entry align="right"><parameter>code</parameter>&nbsp;:</entry>
<entry> error code 
</entry></row>
<row><entry align="right"><parameter>format</parameter>&nbsp;:</entry>
<entry> <function>printf()</function>-style format
</entry></row>
<row><entry align="right"><parameter>...</parameter>&nbsp;:</entry>
<entry> args for <parameter>format</parameter> 
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-propagate-error">g_propagate_error ()</title>
<programlisting>void        g_propagate_error               (<link linkend="GError">GError</link> **dest,
                                             <link linkend="GError">GError</link> *src);</programlisting>
<para>
If <parameter>dest</parameter> is <literal>NULL</literal>, free <parameter>src</parameter>; otherwise,
moves <parameter>src</parameter> into *<parameter>dest</parameter>. *<parameter>dest</parameter> must be <literal>NULL</literal>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>dest</parameter>&nbsp;:</entry>
<entry> error return location
</entry></row>
<row><entry align="right"><parameter>src</parameter>&nbsp;:</entry>
<entry> error to move into the return location
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="g-clear-error">g_clear_error ()</title>
<programlisting>void        g_clear_error                   (<link linkend="GError">GError</link> **err);</programlisting>
<para>
If <parameter>err</parameter> is <literal>NULL</literal>, does nothing. If <parameter>err</parameter> is non-<literal>NULL</literal>,
calls <link linkend="g-error-free">g_error_free</link>() on *<parameter>err</parameter> and sets *<parameter>err</parameter> to <literal>NULL</literal>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>err</parameter>&nbsp;:</entry>
<entry> a <link linkend="GError">GError</link> return location
</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>




</refentry>
