[tracker/miner-fs-refactor] libtracker-sparql: Allow update_array_async to throw errors



commit c77893b63f8c958ff9e1733d7ca054ae64339b79
Author: Jürg Billeter <j bitron ch>
Date:   Mon Oct 11 15:12:46 2010 +0200

    libtracker-sparql: Allow update_array_async to throw errors

 src/libtracker-bus/tracker-bus.vala                |    4 ++--
 src/libtracker-sparql/tracker-backend.vala         |    2 +-
 src/libtracker-sparql/tracker-connection.vala      |    2 +-
 .../update-array-performance-test.c                |    4 +++-
 tests/tracker-steroids/tracker-test.c              |    6 +++++-
 5 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 252785f..3f1f9f4 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -107,7 +107,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
 		}
 	}
 
-	public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) {
+	public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
 		try {
 			if (priority >= GLib.Priority.DEFAULT) {
 				return yield tracker_bus_fd_sparql_update_array_async (connection, sparql, cancellable);
@@ -115,7 +115,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
 				return yield tracker_bus_fd_sparql_batch_update_array_async (connection, sparql, cancellable);
 			}
 		} catch (DBus.Error e) {
-			critical (e.message);
+			throw new Sparql.Error.INTERNAL (e.message);
 		}
 	}
 
diff --git a/src/libtracker-sparql/tracker-backend.vala b/src/libtracker-sparql/tracker-backend.vala
index 4462fc4..8595596 100644
--- a/src/libtracker-sparql/tracker-backend.vala
+++ b/src/libtracker-sparql/tracker-backend.vala
@@ -135,7 +135,7 @@ class Tracker.Sparql.Backend : Connection {
 		yield bus.update_async (sparql, priority, cancellable);
 	}
 
-	public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null)
+	public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError
 	requires (bus != null) {
 		return yield bus.update_array_async (sparql, priority, cancellable);
 	}
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 4cb9df3..554ddb6 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -427,7 +427,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	}
 
 	/* Private API */
-	public async virtual GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) {
+	public async virtual GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
 		warning ("Interface 'update_array_async' not implemented");
 		return null;
 	}
diff --git a/tests/functional-tests/update-array-performance-test.c b/tests/functional-tests/update-array-performance-test.c
index e8f29f1..52c4415 100644
--- a/tests/functional-tests/update-array-performance-test.c
+++ b/tests/functional-tests/update-array-performance-test.c
@@ -73,9 +73,11 @@ async_update_array_callback (GObject      *source_object,
                              gpointer      user_data)
 {
 	AsyncData *data = user_data;
+	GError *error = NULL;
 	GPtrArray *errors;
 
-	errors = tracker_sparql_connection_update_array_finish (connection, result);
+	errors = tracker_sparql_connection_update_array_finish (connection, result, &error);
+	g_assert_no_error (error);
 	g_ptr_array_unref (errors);
 	g_main_loop_quit (data->main_loop);
 }
diff --git a/tests/tracker-steroids/tracker-test.c b/tests/tracker-steroids/tracker-test.c
index 1d15a48..eb57fad 100644
--- a/tests/tracker-steroids/tracker-test.c
+++ b/tests/tracker-steroids/tracker-test.c
@@ -299,10 +299,14 @@ async_update_array_callback (GObject      *source_object,
                              GAsyncResult *result,
                              gpointer      user_data)
 {
+	GError *error = NULL;
 	AsyncData *data = user_data;
 	GPtrArray *errors;
 
-	errors = tracker_sparql_connection_update_array_finish (connection, result);
+	errors = tracker_sparql_connection_update_array_finish (connection, result, &error);
+
+	/* main error is only set on fatal (D-Bus) errors that apply to the whole update */
+	g_assert_no_error (error);
 
 	g_assert (errors->len == 6);
 



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