[glib] gmessages: Mention g_return_if_fail() in g_warning() and g_error() docs



commit 5a642651c799906ec67ebb268cbd8148cd774d0a
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Fri Dec 19 15:27:03 2014 +0000

    gmessages: Mention g_return_if_fail() in g_warning() and g_error() docs
    
    It seems to be common for people to use g_warning() or g_error() as pre-
    and post-condition error reporting functions, which is not really what
    they’re intended for. Similarly, it is generally a sign of bad API
    design to use g_warning() to report errors — use GError instead.
    
    Try and suggest this to the user in the hope that nice code results.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741779

 glib/gmessages.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 507e1ef..7356d0e 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -180,6 +180,10 @@
  *
  * A convenience function/macro to log a warning message.
  *
+ * This is not intended for end user error reporting. Use of #GError is
+ * preferred for that instead, as it allows calling functions to perform actions
+ * conditional on the type of error.
+ *
  * You can make warnings fatal at runtime by setting the `G_DEBUG`
  * environment variable (see
  * [Running GLib Applications](glib-running.html)).
@@ -217,6 +221,10 @@
  *
  * A convenience function/macro to log an error message.
  *
+ * This is not intended for end user error reporting. Use of #GError is
+ * preferred for that instead, as it allows calling functions to perform actions
+ * conditional on the type of error.
+ *
  * Error messages are always fatal, resulting in a call to
  * abort() to terminate the application. This function will
  * result in a core dump; don't use it for errors you expect.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]