[gobject-introspection/wip/transformer: 4/13] [girepository] Fix up error printing



commit 39aa22ca8e2865026ae9ab55fe58f7e20787655a
Author: Colin Walters <walters verbum org>
Date:   Sat Jul 31 06:22:52 2010 -0400

    [girepository] Fix up error printing
    
    We didn't show the right error message if we failed to find
    the symbol; fix this by removing error printing from the
    middle of the dumper, and add it correctly to the toplevel
    dump entry point.

 girepository/gdump.c        |   12 ++++++++++--
 girepository/girepository.c |   11 +++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/girepository/gdump.c b/girepository/gdump.c
index 328f075..3dc2172 100644
--- a/girepository/gdump.c
+++ b/girepository/gdump.c
@@ -68,6 +68,7 @@ static GType
 invoke_get_type (GModule *self, const char *symbol, GError **error)
 {
   GetTypeFunc sym;
+  GType ret;
 
   if (!g_module_symbol (self, symbol, (void**)&sym))
     {
@@ -78,7 +79,15 @@ invoke_get_type (GModule *self, const char *symbol, GError **error)
       return G_TYPE_INVALID;
     }
 
-  return sym ();
+  ret = sym ();
+  if (ret == G_TYPE_INVALID)
+    {
+      g_set_error (error,
+		   G_IO_ERROR,
+		   G_IO_ERROR_FAILED,
+		   "Function '%s' returned G_TYPE_INVALID", symbol);
+    }
+  return ret;
 }
 
 static void
@@ -429,7 +438,6 @@ g_irepository_dump (const char *arg, GError **error)
 
       if (type == G_TYPE_INVALID)
 	{
-          g_printerr ("Invalid GType: '%s'\n", line);
           caught_error = TRUE;
 	  g_free (line);
 	  break;
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 02f86be..84b4a00 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -1323,8 +1323,15 @@ g_irepository_introspect_cb (const char *option_name,
 			     gpointer data,
 			     GError **error)
 {
-  gboolean ret = g_irepository_dump (value, error);
-  exit (ret ? 0 : 1);
+  GError *tmp_error = NULL;
+  gboolean ret = g_irepository_dump (value, &tmp_error);
+  if (!ret)
+    {
+      g_error ("Failed to extract GType data: %s",
+	       tmp_error->message);
+      exit (1);
+    }
+  exit (0);
 }
 
 static const GOptionEntry introspection_args[] = {



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