[Groonga-commit] groonga/groonga-gobject at c4eaffa [master] Add error message to error object

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jan 28 00:02:11 JST 2014


Kouhei Sutou	2014-01-28 00:02:11 +0900 (Tue, 28 Jan 2014)

  New Revision: c4eaffa5a9ca067f5f2efc8f6f99ab088ea1e473
  https://github.com/groonga/groonga-gobject/commit/c4eaffa5a9ca067f5f2efc8f6f99ab088ea1e473

  Message:
    Add error message to error object

  Modified files:
    groonga-gobject/ggrn-context.c
    groonga-gobject/ggrn-internal.c
    groonga-gobject/ggrn-internal.h

  Modified: groonga-gobject/ggrn-context.c (+10 -3)
===================================================================
--- groonga-gobject/ggrn-context.c    2014-01-27 23:58:45 +0900 (f3e20cd)
+++ groonga-gobject/ggrn-context.c    2014-01-28 00:02:11 +0900 (27de485)
@@ -126,6 +126,13 @@ _ggrn_context_get_ctx(GGrnContext *context)
     return priv->ctx;
 }
 
+gboolean
+_ggrn_context_check(GGrnContext *context, GError **error)
+{
+    GGrnContextPrivate *priv = GGRN_CONTEXT_GET_PRIVATE(context);
+    return _ggrn_rc_check(priv->ctx->rc, priv->ctx->errbuf, error);
+}
+
 /**
  * ggrn_context_open_database:
  * @context: A #GGrnContext.
@@ -145,7 +152,7 @@ ggrn_context_open_database(GGrnContext *context,
     dispose_database(priv);
 
     grn_db_open(priv->ctx, path);
-    return _ggrn_rc_check(priv->ctx->rc, error);
+    return _ggrn_context_check(context, error);
 }
 
 /**
@@ -168,7 +175,7 @@ ggrn_context_create_database(GGrnContext *context,
     dispose_database(priv);
 
     grn_db_create(priv->ctx, path, NULL);
-    return _ggrn_rc_check(priv->ctx->rc, error);
+    return _ggrn_context_check(context, error);
 }
 
 /**
@@ -228,7 +235,7 @@ ggrn_context_send_command(GGrnContext  *context,
 
     command_length = strlen(command);
     grn_ctx_send(priv->ctx, command, command_length, flags);
-    return _ggrn_rc_check(priv->ctx->rc, error);
+    return _ggrn_context_check(context, error);
 }
 
 /**

  Modified: groonga-gobject/ggrn-internal.c (+5 -3)
===================================================================
--- groonga-gobject/ggrn-internal.c    2014-01-27 23:58:45 +0900 (dab15ff)
+++ groonga-gobject/ggrn-internal.c    2014-01-28 00:02:11 +0900 (22092f3)
@@ -24,7 +24,7 @@
 #include "ggrn-error.h"
 
 gboolean
-_ggrn_rc_check(grn_rc rc, GError **error)
+_ggrn_rc_check(grn_rc rc, const gchar *message, GError **error)
 {
     GGrnError ggrn_error = (GGrnError)rc;
 
@@ -34,8 +34,10 @@ _ggrn_rc_check(grn_rc rc, GError **error)
 
     g_set_error(error, GGRN_ERROR,
                 ggrn_error,
-                "%s (%d)",
+                "%s (%d)%s%s",
                 ggrn_error_to_string(ggrn_error),
-                rc);
+                rc,
+                message ? ": " : "",
+                message ? message : "");
     return FALSE;
 }

  Modified: groonga-gobject/ggrn-internal.h (+6 -2)
===================================================================
--- groonga-gobject/ggrn-internal.h    2014-01-27 23:58:45 +0900 (8fe0f5b)
+++ groonga-gobject/ggrn-internal.h    2014-01-28 00:02:11 +0900 (6cd4261)
@@ -26,9 +26,13 @@
 
 G_BEGIN_DECLS
 
-G_GNUC_INTERNAL gboolean _ggrn_rc_check (grn_rc rc, GError **error);
+G_GNUC_INTERNAL gboolean _ggrn_rc_check (grn_rc        rc,
+                                         const gchar  *message,
+                                         GError      **error);
 
-G_GNUC_INTERNAL grn_ctx *_ggrn_context_get_ctx (GGrnContext *context);
+G_GNUC_INTERNAL grn_ctx *_ggrn_context_get_ctx (GGrnContext  *context);
+G_GNUC_INTERNAL gboolean _ggrn_context_check   (GGrnContext  *context,
+                                                GError      **error);
 
 G_END_DECLS
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index