2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * gerror.c (g_propagate_error): Free the src error if the dest
+ location is NULL - I'm pretty sure that's what this function was
+ supposed to do.
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* gutils.c (g_find_program_in_path): cleanup docs, sync param
names to those in the header
2000-11-05 Havoc Pennington <hp@pobox.com>
+ * glib/tmpl/error_reporting.sgml: fixes
+
+2000-11-05 Havoc Pennington <hp@pobox.com>
+
* glib/tmpl/spawn.sgml, glib/tmpl/markup.sgml,
glib/tmpl/fileutils.sgml: Added
{
/* Report error to user, and free error */
g_assert (contents == NULL);
- fprintf (stderr, "Unable to read file foo.txt: %s\n", err->message);
+ fprintf (stderr, "Unable to read file: %s\n", err->message);
g_error_free (err);
}
else
}
</programlisting>
Note that <literal>err != NULL</literal> in this example is a
-<emphasis>reliable</emphasis> indicator of whether g_file_get_contents()
-failed. Also, g_file_get_contents() uses the convention that a NULL return value
-means an error occurred (but not all functions use this convention).
+<emphasis>reliable</emphasis> indicator of whether
+g_file_get_contents() failed. Also, g_file_get_contents() uses the
+convention that a NULL return value means an error occurred (but not
+all functions use this convention).
</para>
<para>
freeing the error and resetting the location to NULL. To display an error to the
user, simply display <literal>error->message</literal>, perhaps along with
additional context known only to the calling function (the file being opened, or
-whatever).
+whatever -- though in the g_file_get_contents() case,
+<literal>error->message</literal> already contains a filename).
</para>
<para>
<para>
The error codes are in an enumeration called
<literal><Namespace>_<Module>_Error</literal>; for example,
-#GThreadError or #GExecError.
+#GThreadError or #GSpawnError.
</para>
</listitem>
<listitem>
<para>
-Members of the error code enumeration are called <literal><NAMESPACE>_<MODULE>_ERROR_<CODE></literal>, for example %G_EXEC_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
+Members of the error code enumeration are called <literal><NAMESPACE>_<MODULE>_ERROR_<CODE></literal>, for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
</para>
</listitem>
<listitem>
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><NAMESPACE>_<MODULE>_ERROR_FAILED</literal>, for
-example %G_EXEC_ERROR_FAILED or %G_THREAD_ERROR_FAILED.
+example %G_SPAWN_ERROR_FAILED or %G_THREAD_ERROR_FAILED.
</para>
</listitem>
</itemizedlist>
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>
<listitem>
<para>
</para>
-@domain:
-@code:
-@message:
+@domain: error domain, e.g. #G_FILE_ERROR
+@code: error code, e.g. %G_FILE_ERROR_NOENT
+@message: human-readable informative error message
<!-- ##### FUNCTION g_error_new ##### -->
<para>
* @dest: error return location
* @src: error to move into the return location
*
- * Does nothing if @dest is NULL; otherwise,
+ * If @dest is NULL, free @src; otherwise,
* moves @src into *@dest. *@dest must be NULL.
**/
void
GError *src)
{
g_return_if_fail (src != NULL);
-
- if (dest == NULL)
- return;
- if (*dest != NULL)
- g_warning (ERROR_OVERWRITTEN_WARNING);
-
- *dest = src;
+ if (dest == NULL)
+ {
+ if (src)
+ g_error_free (src);
+ return;
+ }
+ else
+ {
+ if (*dest != NULL)
+ g_warning (ERROR_OVERWRITTEN_WARNING);
+
+ *dest = src;
+ }
}
/**
* @dest: error return location
* @src: error to move into the return location
*
- * Does nothing if @dest is NULL; otherwise,
+ * If @dest is NULL, free @src; otherwise,
* moves @src into *@dest. *@dest must be NULL.
**/
void
GError *src)
{
g_return_if_fail (src != NULL);
-
- if (dest == NULL)
- return;
- if (*dest != NULL)
- g_warning (ERROR_OVERWRITTEN_WARNING);
-
- *dest = src;
+ if (dest == NULL)
+ {
+ if (src)
+ g_error_free (src);
+ return;
+ }
+ else
+ {
+ if (*dest != NULL)
+ g_warning (ERROR_OVERWRITTEN_WARNING);
+
+ *dest = src;
+ }
}
/**