[tracker/libtracker-bus] libtracker-bus: Use correct error domain



commit 4ec364f799b17a319af324ef56405619257481c1
Author: Jürg Billeter <j bitron ch>
Date:   Wed Aug 11 11:56:10 2010 +0200

    libtracker-bus: Use correct error domain

 src/libtracker-bus/tracker-bus-fd-cursor.c |    4 +++
 src/libtracker-bus/tracker-bus-fd-update.c |   31 ++++++++++++++++-----------
 2 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.c b/src/libtracker-bus/tracker-bus-fd-cursor.c
index 0012188..892981c 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.c
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.c
@@ -265,6 +265,8 @@ tracker_bus_fd_query (DBusGConnection  *gconnection,
 	/* message is destroyed by tracker_dbus_send_and_splice */
 
 	if (G_UNLIKELY (inner_error)) {
+		inner_error->domain = TRACKER_SPARQL_ERROR;
+		inner_error->code = 0;
 		g_propagate_error (error, inner_error);
 		g_object_unref (cursor);
 		cursor = NULL;
@@ -289,6 +291,8 @@ query_async_cb (gpointer  buffer,
 	res = G_SIMPLE_ASYNC_RESULT (user_data);
 
 	if (G_UNLIKELY (error)) {
+		error->domain = TRACKER_SPARQL_ERROR;
+		error->code = 0;
 		g_simple_async_result_set_from_error (res, error);
 	} else {
 		TrackerBusFDCursor *cursor;
diff --git a/src/libtracker-bus/tracker-bus-fd-update.c b/src/libtracker-bus/tracker-bus-fd-update.c
index 2838cef..08c8c97 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.c
+++ b/src/libtracker-bus/tracker-bus-fd-update.c
@@ -112,6 +112,22 @@ fast_async_data_new (DBusConnection    *connection,
 	return data;
 }
 
+static GError *
+sparql_error_from_dbus_message (DBusMessage *reply)
+{
+	DBusError dbus_error;
+	GError *error;
+
+	dbus_error_init (&dbus_error);
+	dbus_set_error_from_message (&dbus_error, reply);
+
+	error = g_error_new_literal (TRACKER_SPARQL_ERROR, 0, dbus_error.message);
+
+	dbus_error_free (&dbus_error);
+
+	return error;
+}
+
 static void
 sparql_update_fast_callback (DBusPendingCall *call,
                              void            *user_data)
@@ -125,12 +141,7 @@ sparql_update_fast_callback (DBusPendingCall *call,
 	reply = dbus_pending_call_steal_reply (call);
 
 	if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
-		DBusError dbus_error;
-
-		dbus_error_init (&dbus_error);
-		dbus_set_error_from_message (&dbus_error, reply);
-		dbus_set_g_error (&error, &dbus_error);
-		dbus_error_free (&dbus_error);
+		error = sparql_error_from_dbus_message (reply);
 
 		g_simple_async_result_set_from_error (fad->res, error);
 
@@ -280,13 +291,7 @@ sparql_update_fast (DBusConnection     *connection,
 	reply = dbus_pending_call_steal_reply (call);
 
 	if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
-		DBusError dbus_error;
-
-		dbus_error_init (&dbus_error);
-		dbus_set_error_from_message (&dbus_error, reply);
-		dbus_set_g_error (error, &dbus_error);
-		dbus_pending_call_unref (call);
-		dbus_error_free (&dbus_error);
+		g_propagate_error (error, sparql_error_from_dbus_message (reply));
 
 		return NULL;
 	}



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